diff options
Diffstat (limited to 'core/state/state_object.go')
-rw-r--r-- | core/state/state_object.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/state/state_object.go b/core/state/state_object.go index 2b5dfea7d..d40b42d83 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -87,6 +87,7 @@ type StateObject struct { // during the "update" phase of the state transition. dirtyCode bool // true if the code was updated suicided bool + touched bool deleted bool onDirty func(addr common.Address) // Callback method to mark a state object newly dirty } @@ -139,6 +140,18 @@ func (self *StateObject) markSuicided() { } } +func (c *StateObject) touch() { + c.db.journal = append(c.db.journal, touchChange{ + account: &c.address, + prev: c.touched, + }) + if c.onDirty != nil { + c.onDirty(c.Address()) + c.onDirty = nil + } + c.touched = true +} + func (c *StateObject) getTrie(db trie.Database) *trie.SecureTrie { if c.trie == nil { var err error @@ -231,7 +244,11 @@ func (self *StateObject) CommitTrie(db trie.Database, dbw trie.DatabaseWriter) e func (c *StateObject) AddBalance(amount *big.Int) { // EIP158: We must check emptiness for the objects such that the account // clearing (0,0,0 objects) can take effect. - if amount.Cmp(common.Big0) == 0 && !c.empty() { + if amount.Cmp(common.Big0) == 0 { + if c.empty() { + c.touch() + } + return } c.SetBalance(new(big.Int).Add(c.Balance(), amount)) |