Skip to content

Commit

Permalink
trie: better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Aug 31, 2022
1 parent 279afd7 commit 42cc898
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion trie/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (t *Trie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) e
var err error
tn, err = t.resolveHash(n, prefix)
if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in Trie.Prove", "err", err)
return err
}
default:
Expand Down
12 changes: 5 additions & 7 deletions trie/secure_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package trie

import (
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -80,7 +78,7 @@ func NewStateTrie(owner common.Hash, root common.Hash, db *Database) (*StateTrie
func (t *StateTrie) Get(key []byte) []byte {
res, err := t.TryGet(key)
if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in StateTrie.Get", "err", err)
}
return res
}
Expand All @@ -96,7 +94,7 @@ func (t *StateTrie) TryGetAccount(key []byte) (*types.StateAccount, error) {
var ret types.StateAccount
res, err := t.trie.TryGet(t.hashKey(key))
if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in StateTrie.TGA", "err", err)
return &ret, err
}
if res == nil {
Expand All @@ -113,7 +111,7 @@ func (t *StateTrie) TryGetAccountWithPreHashedKey(key []byte) (*types.StateAccou
var ret types.StateAccount
res, err := t.trie.TryGet(key)
if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in StateTrie.TGAWPHK", "err", err)
return &ret, err
}
if res == nil {
Expand Down Expand Up @@ -152,7 +150,7 @@ func (t *StateTrie) TryUpdateAccount(key []byte, acc *types.StateAccount) error
// stored in the trie.
func (t *StateTrie) Update(key, value []byte) {
if err := t.TryUpdate(key, value); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in StateTrie.Update", "err", err)
}
}

Expand All @@ -177,7 +175,7 @@ func (t *StateTrie) TryUpdate(key, value []byte) error {
// Delete removes any existing value for key from the trie.
func (t *StateTrie) Delete(key []byte) {
if err := t.TryDelete(key); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in StateTrie.Delete", "err", err)
}
}

Expand Down
3 changes: 1 addition & 2 deletions trie/stacktrie.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"bytes"
"encoding/gob"
"errors"
"fmt"
"io"
"sync"

Expand Down Expand Up @@ -207,7 +206,7 @@ func (st *StackTrie) TryUpdate(key, value []byte) error {

func (st *StackTrie) Update(key, value []byte) {
if err := st.TryUpdate(key, value); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in StackTrie.Update", "err", err)
}
}

Expand Down
6 changes: 3 additions & 3 deletions trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (t *Trie) NodeIterator(start []byte) NodeIterator {
func (t *Trie) Get(key []byte) []byte {
res, err := t.TryGet(key)
if err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in Trie.Get", "err", err)
}
return res
}
Expand Down Expand Up @@ -269,7 +269,7 @@ func (t *Trie) tryGetNode(origNode node, path []byte, pos int) (item []byte, new
// stored in the trie.
func (t *Trie) Update(key, value []byte) {
if err := t.TryUpdate(key, value); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in Trie.Update", "err", err)
}
}

Expand Down Expand Up @@ -388,7 +388,7 @@ func (t *Trie) insert(n node, prefix, key []byte, value node) (bool, node, error
// Delete removes any existing value for key from the trie.
func (t *Trie) Delete(key []byte) {
if err := t.TryDelete(key); err != nil {
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log.Error("Unhandled trie error in Trie.Delete", "err", err)
}
}

Expand Down

0 comments on commit 42cc898

Please sign in to comment.