forked from TrueCloudLab/neoneo-go
core: fix unconditional MPT collapsing
It should depend on EnableStateRoot.
This commit is contained in:
parent
6d5e70163d
commit
ea17793aee
1 changed files with 6 additions and 6 deletions
|
@ -877,12 +877,12 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
|
||||||
}
|
}
|
||||||
if bc.config.EnableStateRoot {
|
if bc.config.EnableStateRoot {
|
||||||
bc.dao.MPT.Flush()
|
bc.dao.MPT.Flush()
|
||||||
}
|
// Every persist cycle we also compact our in-memory MPT.
|
||||||
// Every persist cycle we also compact our in-memory MPT.
|
persistedHeight := atomic.LoadUint32(&bc.persistedHeight)
|
||||||
persistedHeight := atomic.LoadUint32(&bc.persistedHeight)
|
if persistedHeight == block.Index-1 {
|
||||||
if persistedHeight == block.Index-1 {
|
// 10 is good and roughly estimated to fit remaining trie into 1M of memory.
|
||||||
// 10 is good and roughly estimated to fit remaining trie into 1M of memory.
|
bc.dao.MPT.Collapse(10)
|
||||||
bc.dao.MPT.Collapse(10)
|
}
|
||||||
}
|
}
|
||||||
bc.topBlock.Store(block)
|
bc.topBlock.Store(block)
|
||||||
atomic.StoreUint32(&bc.blockHeight, block.Index)
|
atomic.StoreUint32(&bc.blockHeight, block.Index)
|
||||||
|
|
Loading…
Reference in a new issue