@@ -85,9 +85,7 @@ type stateObject struct {
8585 // during the "update" phase of the state transition.
8686 dirtyCode bool // true if the code was updated
8787 suicided bool
88- touched bool
8988 deleted bool
90- onDirty func (addr common.Address ) // Callback method to mark a state object newly dirty
9189}
9290
9391// empty returns whether the account is considered empty.
@@ -105,7 +103,7 @@ type Account struct {
105103}
106104
107105// newObject creates a state object.
108- func newObject (db * StateDB , address common.Address , data Account , onDirty func ( addr common. Address ) ) * stateObject {
106+ func newObject (db * StateDB , address common.Address , data Account ) * stateObject {
109107 if data .Balance == nil {
110108 data .Balance = new (big.Int )
111109 }
@@ -119,7 +117,6 @@ func newObject(db *StateDB, address common.Address, data Account, onDirty func(a
119117 data : data ,
120118 cachedStorage : make (Storage ),
121119 dirtyStorage : make (Storage ),
122- onDirty : onDirty ,
123120 }
124121}
125122
@@ -137,23 +134,17 @@ func (self *stateObject) setError(err error) {
137134
138135func (self * stateObject ) markSuicided () {
139136 self .suicided = true
140- if self .onDirty != nil {
141- self .onDirty (self .Address ())
142- self .onDirty = nil
143- }
144137}
145138
146139func (c * stateObject ) touch () {
147- c .db .journal = append (c .db .journal , touchChange {
148- account : & c .address ,
149- prev : c .touched ,
150- prevDirty : c .onDirty == nil ,
140+ c .db .journal .append (touchChange {
141+ account : & c .address ,
151142 })
152- if c .onDirty != nil {
153- c .onDirty (c .Address ())
154- c .onDirty = nil
143+ if c .address == ripemd {
144+ //Explicitly put it in the dirty-cache, which is otherwise
145+ // generated from flattened journals
146+ c .db .journal .dirtyOverride (c .address )
155147 }
156- c .touched = true
157148}
158149
159150func (c * stateObject ) getTrie (db Database ) Trie {
@@ -195,7 +186,7 @@ func (self *stateObject) GetState(db Database, key common.Hash) common.Hash {
195186
196187// SetState updates a value in account storage.
197188func (self * stateObject ) SetState (db Database , key , value common.Hash ) {
198- self .db .journal = append (self . db . journal , storageChange {
189+ self .db .journal . append (storageChange {
199190 account : & self .address ,
200191 key : key ,
201192 prevalue : self .GetState (db , key ),
@@ -207,10 +198,6 @@ func (self *stateObject) setState(key, value common.Hash) {
207198 self .cachedStorage [key ] = value
208199 self .dirtyStorage [key ] = value
209200
210- if self .onDirty != nil {
211- self .onDirty (self .Address ())
212- self .onDirty = nil
213- }
214201}
215202
216203// updateTrie writes cached storage modifications into the object's storage trie.
@@ -274,7 +261,7 @@ func (c *stateObject) SubBalance(amount *big.Int) {
274261}
275262
276263func (self * stateObject ) SetBalance (amount * big.Int ) {
277- self .db .journal = append (self . db . journal , balanceChange {
264+ self .db .journal . append (balanceChange {
278265 account : & self .address ,
279266 prev : new (big.Int ).Set (self .data .Balance ),
280267 })
@@ -283,17 +270,13 @@ func (self *stateObject) SetBalance(amount *big.Int) {
283270
284271func (self * stateObject ) setBalance (amount * big.Int ) {
285272 self .data .Balance = amount
286- if self .onDirty != nil {
287- self .onDirty (self .Address ())
288- self .onDirty = nil
289- }
290273}
291274
292275// Return the gas back to the origin. Used by the Virtual machine or Closures
293276func (c * stateObject ) ReturnGas (gas * big.Int ) {}
294277
295- func (self * stateObject ) deepCopy (db * StateDB , onDirty func ( addr common. Address ) ) * stateObject {
296- stateObject := newObject (db , self .address , self .data , onDirty )
278+ func (self * stateObject ) deepCopy (db * StateDB ) * stateObject {
279+ stateObject := newObject (db , self .address , self .data )
297280 if self .trie != nil {
298281 stateObject .trie = db .db .CopyTrie (self .trie )
299282 }
@@ -333,7 +316,7 @@ func (self *stateObject) Code(db Database) []byte {
333316
334317func (self * stateObject ) SetCode (codeHash common.Hash , code []byte ) {
335318 prevcode := self .Code (self .db .db )
336- self .db .journal = append (self . db . journal , codeChange {
319+ self .db .journal . append (codeChange {
337320 account : & self .address ,
338321 prevhash : self .CodeHash (),
339322 prevcode : prevcode ,
@@ -345,14 +328,10 @@ func (self *stateObject) setCode(codeHash common.Hash, code []byte) {
345328 self .code = code
346329 self .data .CodeHash = codeHash [:]
347330 self .dirtyCode = true
348- if self .onDirty != nil {
349- self .onDirty (self .Address ())
350- self .onDirty = nil
351- }
352331}
353332
354333func (self * stateObject ) SetNonce (nonce uint64 ) {
355- self .db .journal = append (self . db . journal , nonceChange {
334+ self .db .journal . append (nonceChange {
356335 account : & self .address ,
357336 prev : self .data .Nonce ,
358337 })
@@ -361,10 +340,6 @@ func (self *stateObject) SetNonce(nonce uint64) {
361340
362341func (self * stateObject ) setNonce (nonce uint64 ) {
363342 self .data .Nonce = nonce
364- if self .onDirty != nil {
365- self .onDirty (self .Address ())
366- self .onDirty = nil
367- }
368343}
369344
370345func (self * stateObject ) CodeHash () []byte {
0 commit comments