diff options
Diffstat (limited to 'core/blockchain.go')
-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 } |