From da591470147689bb5978eaaff28468d19af61614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 4 May 2020 15:14:08 +0300 Subject: [PATCH] core/state/snapshot: release iterator after verification --- core/state/snapshot/conversion.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/state/snapshot/conversion.go b/core/state/snapshot/conversion.go index fc9b7d1acf..dee9ff0bf2 100644 --- a/core/state/snapshot/conversion.go +++ b/core/state/snapshot/conversion.go @@ -63,11 +63,15 @@ func VerifyState(snaptree *Tree, root common.Hash) error { if err != nil { return err } + defer acctIt.Release() + got, err := generateTrieRoot(acctIt, common.Hash{}, stdGenerate, func(account common.Hash, stat *generateStats) common.Hash { storageIt, err := snaptree.StorageIterator(root, account, common.Hash{}) if err != nil { return common.Hash{} } + defer storageIt.Release() + hash, err := generateTrieRoot(storageIt, account, stdGenerate, nil, stat, false) if err != nil { return common.Hash{} @@ -79,7 +83,7 @@ func VerifyState(snaptree *Tree, root common.Hash) error { return err } if got != root { - return fmt.Errorf("State root hash mismatch, got %x, want %x", got, root) + return fmt.Errorf("state root hash mismatch: got %x, want %x", got, root) } return nil }