diff options
author | Sonic <sonic@dexon.org> | 2018-11-26 14:50:20 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:19 +0800 |
commit | de6031e18c5a134fc6a4d72fdd1237201e42b720 (patch) | |
tree | 33066093a9c40e2280890b56919b92fc3b49ad51 | |
parent | 19ec7a0cd8f05be8761a4b074dd2d784fab8ae37 (diff) | |
download | go-tangerine-de6031e18c5a134fc6a4d72fdd1237201e42b720.tar go-tangerine-de6031e18c5a134fc6a4d72fdd1237201e42b720.tar.gz go-tangerine-de6031e18c5a134fc6a4d72fdd1237201e42b720.tar.bz2 go-tangerine-de6031e18c5a134fc6a4d72fdd1237201e42b720.tar.lz go-tangerine-de6031e18c5a134fc6a4d72fdd1237201e42b720.tar.xz go-tangerine-de6031e18c5a134fc6a4d72fdd1237201e42b720.tar.zst go-tangerine-de6031e18c5a134fc6a4d72fdd1237201e42b720.zip |
core: commit states at snapshot height (#49)
-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 81e9f05b2..2b172b15c 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 } |