diff options
Diffstat (limited to 'core/state')
-rw-r--r-- | core/state/state_object.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/state/state_object.go b/core/state/state_object.go index bfc4ebc6c..6d2455d79 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -336,6 +336,22 @@ func (self *StateObject) Nonce() uint64 { return self.nonce } +func (self *StateObject) EachStorage(cb func(key, value []byte)) { + // When iterating over the storage check the cache first + for h, v := range self.storage { + cb([]byte(h), v.Bytes()) + } + + it := self.State.trie.Iterator() + for it.Next() { + // ignore cached values + key := self.State.trie.GetKey(it.Key) + if _, ok := self.storage[string(key)]; !ok { + cb(key, it.Value) + } + } +} + // // Encoding // |