diff --git a/pkg/core/mpt/base.go b/pkg/core/mpt/base.go index 49c7b2d59..0cfe62aa3 100644 --- a/pkg/core/mpt/base.go +++ b/pkg/core/mpt/base.go @@ -29,6 +29,18 @@ type BaseNodeIface interface { SetFlushed() } +type flushedNode interface { + setCache([]byte, util.Uint256) +} + +func (b *BaseNode) setCache(bs []byte, h util.Uint256) { + b.bytes = bs + b.hash = h + b.bytesValid = true + b.hashValid = true + b.isFlushed = true +} + // getHash returns a hash of this BaseNode. func (b *BaseNode) getHash(n Node) util.Uint256 { if !b.hashValid { diff --git a/pkg/core/mpt/trie.go b/pkg/core/mpt/trie.go index 08d128d88..883eed4b0 100644 --- a/pkg/core/mpt/trie.go +++ b/pkg/core/mpt/trie.go @@ -354,6 +354,7 @@ func (t *Trie) getFromStore(h util.Uint256) (Node, error) { if r.Err != nil { return nil, r.Err } + n.Node.(flushedNode).setCache(data, h) return n.Node, nil }