trie: added error handling

Created alternate versions of Trie and SecureTrie functions that can return a MissingNodeError (used by ODR services)
This commit is contained in:
zsfelfoldi
2015-11-25 18:28:21 +01:00
parent 66d47ced48
commit 52904ae32f
7 changed files with 346 additions and 71 deletions

View File

@ -7,6 +7,8 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
)
@ -39,7 +41,14 @@ func (t *Trie) Prove(key []byte) []rlp.RawValue {
case nil:
return nil
case hashNode:
tn = t.resolveHash(n)
var err error
tn, err = t.resolveHash(n, nil, nil)
if err != nil {
if glog.V(logger.Error) {
glog.Errorf("Unhandled trie error: %v", err)
}
return nil
}
default:
panic(fmt.Sprintf("%T: invalid node: %v", tn, tn))
}