aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2018-11-26 14:50:20 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commit18d0137e06783db5e331a87f198fd2133eb0d797 (patch)
tree93d7636c0624b4f579cacb682cca3e888a8985f6 /core
parent34dcce67dfe99e7643aee74258957a489b368a32 (diff)
downloaddexon-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.go9
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
}