aboutsummaryrefslogtreecommitdiffstats
path: root/ptrie/trie.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-11-19 23:56:01 +0800
committerobscuren <geffobscura@gmail.com>2014-11-19 23:56:01 +0800
commitb05e63c34d335e65c8c76ed9a9401b74170db617 (patch)
tree2c8a8fe2710592c6ded4b226d8930c2c11c0db9e /ptrie/trie.go
parentcab7e6000e20413d697d07a1a6b2abcc85dfc2e1 (diff)
downloaddexon-b05e63c34d335e65c8c76ed9a9401b74170db617.tar
dexon-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.gz
dexon-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.bz2
dexon-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.lz
dexon-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.xz
dexon-b05e63c34d335e65c8c76ed9a9401b74170db617.tar.zst
dexon-b05e63c34d335e65c8c76ed9a9401b74170db617.zip
Added paranoia check for tries
Diffstat (limited to 'ptrie/trie.go')
-rw-r--r--ptrie/trie.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/ptrie/trie.go b/ptrie/trie.go
index 0ef498b10..4b0f20d8c 100644
--- a/ptrie/trie.go
+++ b/ptrie/trie.go
@@ -10,6 +10,17 @@ import (
"github.com/ethereum/go-ethereum/trie"
)
+func ParanoiaCheck(t1 *Trie, backend Backend) (bool, *Trie) {
+ t2 := New(nil, backend)
+
+ it := t1.Iterator()
+ for it.Next() {
+ t2.Update(it.Key, it.Value)
+ }
+
+ return bytes.Compare(t2.Hash(), t1.Hash()) == 0, t2
+}
+
type Trie struct {
mu sync.Mutex
root Node
@@ -293,7 +304,7 @@ func (self *Trie) store(node Node) interface{} {
data := ethutil.Encode(node)
if len(data) >= 32 {
key := crypto.Sha3(data)
- self.cache.Set(key, data)
+ self.cache.Put(key, data)
return key
}