aboutsummaryrefslogtreecommitdiffstats
path: root/core/state/statedb.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/state/statedb.go')
-rw-r--r--core/state/statedb.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 515ff57bf..216667ce9 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -247,18 +247,20 @@ func (self *StateDB) GetCodeHash(addr common.Address) common.Hash {
return common.BytesToHash(stateObject.CodeHash())
}
-func (self *StateDB) GetState(addr common.Address, bhash common.Hash) common.Hash {
+// GetState retrieves a value from the given account's storage trie.
+func (self *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {
stateObject := self.getStateObject(addr)
if stateObject != nil {
- return stateObject.GetState(self.db, bhash)
+ return stateObject.GetState(self.db, hash)
}
return common.Hash{}
}
-func (self *StateDB) GetStateOriginal(addr common.Address, bhash common.Hash) common.Hash {
+// GetCommittedState retrieves a value from the given account's committed storage trie.
+func (self *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash {
stateObject := self.getStateObject(addr)
if stateObject != nil {
- return stateObject.GetOriginalStateValue(self.db, bhash)
+ return stateObject.GetCommittedState(self.db, hash)
}
return common.Hash{}
}
@@ -454,19 +456,14 @@ func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common
if so == nil {
return
}
-
- // When iterating over the storage check the cache first
- for h, value := range so.cachedStorage {
- cb(h, value)
- }
-
it := trie.NewIterator(so.getTrie(db.db).NodeIterator(nil))
for it.Next() {
- // ignore cached values
key := common.BytesToHash(db.trie.GetKey(it.Key))
- if _, ok := so.cachedStorage[key]; !ok {
- cb(key, common.BytesToHash(it.Value))
+ if value, dirty := so.dirtyStorage[key]; dirty {
+ cb(key, value)
+ continue
}
+ cb(key, common.BytesToHash(it.Value))
}
}