Skip to content

Commit

Permalink
Apply self-review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jan 9, 2023
1 parent 255072f commit 9a278fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/runtime/storage/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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++
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/trie/child_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (t *Trie) SetChild(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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a278fe

Please sign in to comment.