From ea17793aee92cbfc2bb9fccbe6157fbec7531f59 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 24 Jun 2020 14:41:57 +0300 Subject: [PATCH] core: fix unconditional MPT collapsing It should depend on EnableStateRoot. --- pkg/core/blockchain.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index d7cda96bb..fa7cc0e0b 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -877,12 +877,12 @@ func (bc *Blockchain) storeBlock(block *block.Block) error { } if bc.config.EnableStateRoot { bc.dao.MPT.Flush() - } - // Every persist cycle we also compact our in-memory MPT. - persistedHeight := atomic.LoadUint32(&bc.persistedHeight) - if persistedHeight == block.Index-1 { - // 10 is good and roughly estimated to fit remaining trie into 1M of memory. - bc.dao.MPT.Collapse(10) + // Every persist cycle we also compact our in-memory MPT. + persistedHeight := atomic.LoadUint32(&bc.persistedHeight) + if persistedHeight == block.Index-1 { + // 10 is good and roughly estimated to fit remaining trie into 1M of memory. + bc.dao.MPT.Collapse(10) + } } bc.topBlock.Store(block) atomic.StoreUint32(&bc.blockHeight, block.Index)