diff options
author | obscuren <geffobscura@gmail.com> | 2014-10-29 21:20:42 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-10-29 21:20:42 +0800 |
commit | 9e2f071d26d5c4ed343d2a91e48fec4e7751b99d (patch) | |
tree | fdfde82ceb0c6736b82c08c7002055ee95cfef67 /ethtrie/trie.go | |
parent | fb4113dab4df8480c77bdcb707fa6b5408755b79 (diff) | |
download | go-tangerine-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar go-tangerine-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.gz go-tangerine-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.bz2 go-tangerine-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.lz go-tangerine-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.xz go-tangerine-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.tar.zst go-tangerine-9e2f071d26d5c4ed343d2a91e48fec4e7751b99d.zip |
Removed events from the state manager
Diffstat (limited to 'ethtrie/trie.go')
-rw-r--r-- | ethtrie/trie.go | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/ethtrie/trie.go b/ethtrie/trie.go index 9bbe111d2..6db25db05 100644 --- a/ethtrie/trie.go +++ b/ethtrie/trie.go @@ -168,7 +168,24 @@ func New(db ethutil.Database, Root interface{}) *Trie { r := copyRoot(Root) p := copyRoot(Root) - return &Trie{cache: NewCache(db), Root: r, prevRoot: p} + trie := &Trie{cache: NewCache(db), Root: r, prevRoot: p} + trie.setRoot(Root) + + return trie +} + +func (self *Trie) setRoot(root interface{}) { + switch t := root.(type) { + case string: + if t == "" { + root = ethcrypto.Sha3([]byte("")) + } + self.Root = root + case []byte: + self.Root = root + default: + self.Root = self.cache.PutValue(root, true) + } } /* @@ -182,14 +199,7 @@ func (t *Trie) Update(key, value string) { k := CompactHexDecode(key) root := t.UpdateState(t.Root, k, value) - switch root.(type) { - case string: - t.Root = root - case []byte: - t.Root = root - default: - t.Root = t.cache.PutValue(root, true) - } + t.setRoot(root) } func (t *Trie) Get(key string) string { @@ -209,14 +219,7 @@ func (t *Trie) Delete(key string) { k := CompactHexDecode(key) root := t.deleteState(t.Root, k) - switch root.(type) { - case string: - t.Root = root - case []byte: - t.Root = root - default: - t.Root = t.cache.PutValue(root, true) - } + t.setRoot(root) } func (self *Trie) GetRoot() []byte { |