aboutsummaryrefslogtreecommitdiffstats
path: root/trie
diff options
context:
space:
mode:
Diffstat (limited to 'trie')
-rw-r--r--trie/proof.go5
-rw-r--r--trie/secure_trie.go5
2 files changed, 8 insertions, 2 deletions
diff --git a/trie/proof.go b/trie/proof.go
index 1f8f76b1b..298f648c4 100644
--- a/trie/proof.go
+++ b/trie/proof.go
@@ -125,7 +125,7 @@ func VerifyProof(rootHash common.Hash, key []byte, proof []rlp.RawValue) (value
}
func get(tn node, key []byte) ([]byte, node) {
- for len(key) > 0 {
+ for {
switch n := tn.(type) {
case *shortNode:
if len(key) < len(n.Key) || !bytes.Equal(n.Key, key[:len(n.Key)]) {
@@ -140,9 +140,10 @@ func get(tn node, key []byte) ([]byte, node) {
return key, n
case nil:
return key, nil
+ case valueNode:
+ return nil, n
default:
panic(fmt.Sprintf("%T: invalid node: %v", tn, tn))
}
}
- return nil, tn.(valueNode)
}
diff --git a/trie/secure_trie.go b/trie/secure_trie.go
index 37d1d4b09..20c303f31 100644
--- a/trie/secure_trie.go
+++ b/trie/secure_trie.go
@@ -156,6 +156,11 @@ func (t *SecureTrie) Root() []byte {
return t.trie.Root()
}
+func (t *SecureTrie) Copy() *SecureTrie {
+ cpy := *t
+ return &cpy
+}
+
// NodeIterator returns an iterator that returns nodes of the underlying trie. Iteration
// starts at the key after the given start key.
func (t *SecureTrie) NodeIterator(start []byte) NodeIterator {