diff options
author | Sonic <sonic@dexon.org> | 2018-11-26 14:50:20 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 18d0137e06783db5e331a87f198fd2133eb0d797 (patch) | |
tree | 93d7636c0624b4f579cacb682cca3e888a8985f6 /core | |
parent | 34dcce67dfe99e7643aee74258957a489b368a32 (diff) | |
download | dexon-18d0137e06783db5e331a87f198fd2133eb0d797.tar.gz dexon-18d0137e06783db5e331a87f198fd2133eb0d797.tar.zst dexon-18d0137e06783db5e331a87f198fd2133eb0d797.zip |
core: commit states at snapshot height (#49)
Diffstat (limited to 'core')
-rw-r--r-- | core/blockchain.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/blockchain.go b/core/blockchain.go index b9de195dc..711457ac1 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1093,8 +1093,13 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. } triedb := bc.stateCache.TrieDB() - // If we're running an archive node, always flush - if bc.cacheConfig.Disabled { + if _, ok := bc.GetRoundHeight(block.Round()); !ok { + bc.storeRoundHeight(block.Round(), block.NumberU64()) + } + height, _ := bc.GetRoundHeight(block.Round()) + + // If we're running an archive node or the block is snapshot height, always flush + if bc.cacheConfig.Disabled || height == block.NumberU64() { if err := triedb.Commit(root, false); err != nil { return NonStatTy, err } |