diff options
author | bojie <bojie@dexon.org> | 2019-01-07 15:40:56 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 7285c3b0af76e2e470ba3917b006264a06644246 (patch) | |
tree | 97e0e582ff951d5bedddb22cf3f4201e44bbb358 /core/rawdb | |
parent | f8bd72b9e430960790db8972826a541425b4c552 (diff) | |
download | dexon-7285c3b0af76e2e470ba3917b006264a06644246.tar dexon-7285c3b0af76e2e470ba3917b006264a06644246.tar.gz dexon-7285c3b0af76e2e470ba3917b006264a06644246.tar.bz2 dexon-7285c3b0af76e2e470ba3917b006264a06644246.tar.lz dexon-7285c3b0af76e2e470ba3917b006264a06644246.tar.xz dexon-7285c3b0af76e2e470ba3917b006264a06644246.tar.zst dexon-7285c3b0af76e2e470ba3917b006264a06644246.zip |
app: implement logic for prepare/verify correctly when chain number change (#118)
Diffstat (limited to 'core/rawdb')
-rw-r--r-- | core/rawdb/accessors_chain.go | 15 | ||||
-rw-r--r-- | core/rawdb/schema.go | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 801ad9362..5e23bef8f 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -348,6 +348,21 @@ func WriteBlock(db DatabaseWriter, block *types.Block) { WriteHeader(db, block.Header()) } +// ReadLastRoundNumber get current round number. +func ReadLastRoundNumber(db DatabaseReader) (uint64, error) { + number, err := db.Get(lastRoundNum) + if err != nil { + return 0, err + } + + return new(big.Int).SetBytes(number).Uint64(), nil +} + +// WriteLastRoundNumber write current round number. +func WriteLastRoundNumber(db DatabaseWriter, number uint64) error { + return db.Put(lastRoundNum, new(big.Int).SetUint64(number).Bytes()) +} + // DeleteBlock removes all block data associated with a hash. func DeleteBlock(db DatabaseDeleter, hash common.Hash, number uint64) { DeleteReceipts(db, hash, number) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 87a56c0ba..954ebfc1d 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -63,6 +63,8 @@ var ( // Chain index prefixes (use `i` + single byte to avoid mixing data types). BloomBitsIndexPrefix = []byte("iB") // BloomBitsIndexPrefix is the data table of a chain indexer to track its progress + lastRoundNum = []byte("LastRoundNum") + preimageCounter = metrics.NewRegisteredCounter("db/preimage/total", nil) preimageHitCounter = metrics.NewRegisteredCounter("db/preimage/hits", nil) ) |