diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-03 19:25:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-03 19:25:44 +0800 |
commit | b909a5ec18d30456c6028593448233bba0937482 (patch) | |
tree | e6907d706ce68180550242444a11b4300ec65a4e | |
parent | 1650b59cd93a29ea54328656a9318ffb10889ae5 (diff) | |
download | go-tangerine-b909a5ec18d30456c6028593448233bba0937482.tar.gz go-tangerine-b909a5ec18d30456c6028593448233bba0937482.tar.zst go-tangerine-b909a5ec18d30456c6028593448233bba0937482.zip |
Trie => SecureTrie
-rw-r--r-- | state/state_object.go | 2 | ||||
-rw-r--r-- | state/statedb.go | 4 | ||||
-rw-r--r-- | trie/secure_trie.go | 4 |
3 files changed, 7 insertions, 3 deletions
diff --git a/state/state_object.go b/state/state_object.go index 487952a02..51ec95efa 100644 --- a/state/state_object.go +++ b/state/state_object.go @@ -290,7 +290,7 @@ func (c *StateObject) Init() Code { return c.initCode } -func (self *StateObject) Trie() *trie.Trie { +func (self *StateObject) Trie() *trie.SecureTrie { return self.State.trie } diff --git a/state/statedb.go b/state/statedb.go index 7e2b24b94..ee37c2e68 100644 --- a/state/statedb.go +++ b/state/statedb.go @@ -18,7 +18,7 @@ var statelogger = logger.NewLogger("STATE") // * Accounts type StateDB struct { db ethutil.Database - trie *trie.Trie + trie *trie.SecureTrie stateObjects map[string]*StateObject @@ -29,7 +29,7 @@ type StateDB struct { // Create a new state from a given trie func New(root []byte, db ethutil.Database) *StateDB { - trie := trie.New(ethutil.CopyBytes(root), db) + trie := trie.NewSecure(ethutil.CopyBytes(root), db) return &StateDB{db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: make(map[string]*big.Int)} } diff --git a/trie/secure_trie.go b/trie/secure_trie.go index f49547ed8..b9fa376b8 100644 --- a/trie/secure_trie.go +++ b/trie/secure_trie.go @@ -30,3 +30,7 @@ func (self *SecureTrie) Delete(key []byte) Node { func (self *SecureTrie) DeleteString(key string) Node { return self.Delete([]byte(key)) } + +func (self *SecureTrie) Copy() *SecureTrie { + return &SecureTrie{self.Trie.Copy()} +} |