forked from TrueCloudLab/neoneo-go
core: restore MPT collapsing logic
Fix #1867, revert part of bf20db09e0
.
This commit is contained in:
parent
99ca0b2578
commit
9b15ab48ad
1 changed files with 7 additions and 0 deletions
|
@ -754,6 +754,13 @@ func (bc *Blockchain) storeBlock(block *block.Block, txpool *mempool.Pool) error
|
|||
writeBuf.Reset()
|
||||
}
|
||||
}
|
||||
// Every persist cycle we also compact our in-memory MPT. It's flushed
|
||||
// already in AddMPTBatch, so collapsing it is safe.
|
||||
persistedHeight := atomic.LoadUint32(&bc.persistedHeight)
|
||||
if persistedHeight == block.Index-1 {
|
||||
// 10 is good and roughly estimated to fit remaining trie into 1M of memory.
|
||||
mpt.Collapse(10)
|
||||
}
|
||||
|
||||
bc.lock.Lock()
|
||||
_, err = cache.Persist()
|
||||
|
|
Loading…
Reference in a new issue