From 4e6025766869153f8a844caca893746fd2a598b2 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Wed, 16 Nov 2022 09:04:26 +0000 Subject: [PATCH] Apply self-review feedback --- lib/runtime/storage/trie.go | 6 +++--- lib/trie/child_storage.go | 8 ++++---- lib/trie/trie.go | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/runtime/storage/trie.go b/lib/runtime/storage/trie.go index ebd3b4b76a..7da1665792 100644 --- a/lib/runtime/storage/trie.go +++ b/lib/runtime/storage/trie.go @@ -193,7 +193,7 @@ func (s *TrieState) DeleteChildLimit(key []byte, limit *[]byte) ( if limit == nil { err = s.t.DeleteChild(key) if err != nil { - return 0, false, err + return 0, false, fmt.Errorf("deleting child trie: %w", err) } return qtyEntries, true, nil @@ -212,7 +212,7 @@ func (s *TrieState) DeleteChildLimit(key []byte, limit *[]byte) ( // values within the tries, which is used for online pruning. err = tr.Delete([]byte(k)) if err != nil { - return deleted, allDeleted, fmt.Errorf("deleting from child trie at key 0x%x: %w", key, err) + return deleted, allDeleted, fmt.Errorf("deleting from child trie located at key 0x%x: %w", key, err) } deleted++ @@ -247,7 +247,7 @@ func (s *TrieState) ClearPrefixInChild(keyToChild, prefix []byte) error { err = child.ClearPrefix(prefix) if err != nil { - return fmt.Errorf("clearing prefix in child trie at key 0x%x: %w", keyToChild, err) + return fmt.Errorf("clearing prefix in child trie located at key 0x%x: %w", keyToChild, err) } return nil diff --git a/lib/trie/child_storage.go b/lib/trie/child_storage.go index 6eb869b2a9..11f5697d89 100644 --- a/lib/trie/child_storage.go +++ b/lib/trie/child_storage.go @@ -30,7 +30,7 @@ func (t *Trie) PutChild(keyToChild []byte, child *Trie) error { err = t.Put(key, childHash.ToBytes()) if err != nil { - return fmt.Errorf("putting child trie root hash %s in main trie: %w", childHash, err) + return fmt.Errorf("putting child trie root hash %s in trie: %w", childHash, err) } t.childTries[childHash] = child @@ -65,7 +65,7 @@ func (t *Trie) PutIntoChild(keyToChild, key, value []byte) error { err = child.Put(key, value) if err != nil { - return fmt.Errorf("putting into child trie at key 0x%x: %w", keyToChild, err) + return fmt.Errorf("putting into child trie located at key 0x%x: %w", keyToChild, err) } childHash, err := child.Hash() @@ -103,7 +103,7 @@ func (t *Trie) DeleteChild(keyToChild []byte) (err error) { err = t.Delete(key) if err != nil { - return fmt.Errorf("deleting child trie at key 0x%x: %w", key, err) + return fmt.Errorf("deleting child trie located at key 0x%x: %w", keyToChild, err) } return nil } @@ -120,7 +120,7 @@ func (t *Trie) ClearFromChild(keyToChild, key []byte) error { err = child.Delete(key) if err != nil { - return fmt.Errorf("deleting from child trie at key 0x%x: %w", keyToChild, err) + return fmt.Errorf("deleting from child trie located at key 0x%x: %w", keyToChild, err) } return nil diff --git a/lib/trie/trie.go b/lib/trie/trie.go index c2af7a3fed..5a35849347 100644 --- a/lib/trie/trie.go +++ b/lib/trie/trie.go @@ -777,8 +777,6 @@ func (t *Trie) ClearPrefixLimit(prefixLE []byte, limit uint32) ( root, deleted, _, allDeleted, err := t.clearPrefixLimitAtNode( t.root, prefix, limit, pendingDeletedMerkleValues) if err != nil { - // Note: no need to wrap the error really since the private function has - // the same name as the exported function `ClearPrefixLimit`. return 0, false, err } t.root = root