mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
block_height is int32
This commit is contained in:
parent
ddb2b01631
commit
df299d03c4
@ -10,38 +10,6 @@ import (
|
||||
"github.com/tendermint/tmsp/types"
|
||||
)
|
||||
|
||||
//-----------------------------------------
|
||||
// persist the last block info
|
||||
|
||||
var lastBlockKey = []byte("lastblock")
|
||||
|
||||
// Get the last block from the db
|
||||
func LoadLastBlock(db dbm.DB) (lastBlock types.LastBlockInfo) {
|
||||
buf := db.Get(lastBlockKey)
|
||||
if len(buf) != 0 {
|
||||
r, n, err := bytes.NewReader(buf), new(int), new(error)
|
||||
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
|
||||
if *err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
Exit(Fmt("Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
}
|
||||
// TODO: ensure that buf is completely read.
|
||||
}
|
||||
|
||||
return lastBlock
|
||||
}
|
||||
|
||||
func SaveLastBlock(db dbm.DB, lastBlock types.LastBlockInfo) {
|
||||
log.Notice("Saving block", "height", lastBlock.BlockHeight, "hash", lastBlock.BlockHash, "root", lastBlock.AppHash)
|
||||
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
||||
wire.WriteBinary(lastBlock, buf, n, err)
|
||||
if *err != nil {
|
||||
// TODO
|
||||
PanicCrisis(*err)
|
||||
}
|
||||
db.Set(lastBlockKey, buf.Bytes())
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
type PersistentDummyApplication struct {
|
||||
@ -120,3 +88,35 @@ func (app *PersistentDummyApplication) BeginBlock(hash []byte, header *types.Hea
|
||||
func (app *PersistentDummyApplication) EndBlock(height uint64) (diffs []*types.Validator) {
|
||||
return nil
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// persist the last block info
|
||||
|
||||
var lastBlockKey = []byte("lastblock")
|
||||
|
||||
// Get the last block from the db
|
||||
func LoadLastBlock(db dbm.DB) (lastBlock types.LastBlockInfo) {
|
||||
buf := db.Get(lastBlockKey)
|
||||
if len(buf) != 0 {
|
||||
r, n, err := bytes.NewReader(buf), new(int), new(error)
|
||||
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
|
||||
if *err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
Exit(Fmt("Data has been corrupted or its spec has changed: %v\n", *err))
|
||||
}
|
||||
// TODO: ensure that buf is completely read.
|
||||
}
|
||||
|
||||
return lastBlock
|
||||
}
|
||||
|
||||
func SaveLastBlock(db dbm.DB, lastBlock types.LastBlockInfo) {
|
||||
log.Notice("Saving block", "height", lastBlock.BlockHeight, "hash", lastBlock.BlockHash, "root", lastBlock.AppHash)
|
||||
buf, n, err := new(bytes.Buffer), new(int), new(error)
|
||||
wire.WriteBinary(lastBlock, buf, n, err)
|
||||
if *err != nil {
|
||||
// TODO
|
||||
PanicCrisis(*err)
|
||||
}
|
||||
db.Set(lastBlockKey, buf.Bytes())
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ message TMSPInfo {
|
||||
}
|
||||
|
||||
message LastBlockInfo {
|
||||
uint64 block_height = 1;
|
||||
int32 block_height = 1;
|
||||
bytes block_hash = 2;
|
||||
bytes app_hash = 3;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user