Skip to content

Commit 5876566

Browse files
authored
Merge pull request #21023 from karalabe/snapshot-verify-iterator-release
core/state/snapshot: release iterator after verification
2 parents 5e45db7 + da59147 commit 5876566

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎core/state/snapshot/conversion.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ func VerifyState(snaptree *Tree, root common.Hash) error {
6363
if err != nil {
6464
return err
6565
}
66+
defer acctIt.Release()
67+
6668
got, err := generateTrieRoot(acctIt, common.Hash{}, stdGenerate, func(account common.Hash, stat *generateStats) common.Hash {
6769
storageIt, err := snaptree.StorageIterator(root, account, common.Hash{})
6870
if err != nil {
6971
return common.Hash{}
7072
}
73+
defer storageIt.Release()
74+
7175
hash, err := generateTrieRoot(storageIt, account, stdGenerate, nil, stat, false)
7276
if err != nil {
7377
return common.Hash{}
@@ -79,7 +83,7 @@ func VerifyState(snaptree *Tree, root common.Hash) error {
7983
return err
8084
}
8185
if got != root {
82-
return fmt.Errorf("State root hash mismatch, got %x, want %x", got, root)
86+
return fmt.Errorf("state root hash mismatch: got %x, want %x", got, root)
8387
}
8488
return nil
8589
}

0 commit comments

Comments
 (0)