forked from TrueCloudLab/neoneo-go
mpt: fill cached fields when getting node from store
Node which has been got from store shouldn't be flushed again.
This commit is contained in:
parent
fd9ff4102a
commit
1c559634aa
2 changed files with 13 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue