@@ -207,7 +207,7 @@ func (s *StateDB) Error() error {
207
207
}
208
208
209
209
func (s * StateDB ) AddLog (log * types.Log ) {
210
- s .journal .append ( addLogChange { txhash : s .thash } )
210
+ s .journal .JournalLog ( s .thash )
211
211
212
212
log .TxHash = s .thash
213
213
log .TxIndex = uint (s .txIndex )
@@ -238,7 +238,7 @@ func (s *StateDB) Logs() []*types.Log {
238
238
// AddPreimage records a SHA3 preimage seen by the VM.
239
239
func (s * StateDB ) AddPreimage (hash common.Hash , preimage []byte ) {
240
240
if _ , ok := s .preimages [hash ]; ! ok {
241
- s .journal .append ( addPreimageChange { hash : hash } )
241
+ s .journal .JournalAddPreimage ( hash )
242
242
pi := make ([]byte , len (preimage ))
243
243
copy (pi , preimage )
244
244
s .preimages [hash ] = pi
@@ -252,14 +252,14 @@ func (s *StateDB) Preimages() map[common.Hash][]byte {
252
252
253
253
// AddRefund adds gas to the refund counter
254
254
func (s * StateDB ) AddRefund (gas uint64 ) {
255
- s .journal .append ( refundChange { prev : s .refund } )
255
+ s .journal .JournalRefund ( s .refund )
256
256
s .refund += gas
257
257
}
258
258
259
259
// SubRefund removes gas from the refund counter.
260
260
// This method will panic if the refund counter goes below zero
261
261
func (s * StateDB ) SubRefund (gas uint64 ) {
262
- s .journal .append ( refundChange { prev : s .refund } )
262
+ s .journal .JournalRefundChange ( s .refund )
263
263
if gas > s .refund {
264
264
panic (fmt .Sprintf ("Refund counter below zero (gas: %d > refund: %d)" , gas , s .refund ))
265
265
}
@@ -447,11 +447,7 @@ func (s *StateDB) SelfDestruct(addr common.Address) {
447
447
if stateObject == nil {
448
448
return
449
449
}
450
- s .journal .append (selfDestructChange {
451
- account : & addr ,
452
- prev : stateObject .selfDestructed ,
453
- prevbalance : new (uint256.Int ).Set (stateObject .Balance ()),
454
- })
450
+ s .journal .JournalDestruct (addr , stateObject .selfDestructed , stateObject .Balance ())
455
451
stateObject .markSelfdestructed ()
456
452
stateObject .data .Balance = new (uint256.Int )
457
453
}
@@ -475,11 +471,7 @@ func (s *StateDB) SetTransientState(addr common.Address, key, value common.Hash)
475
471
if prev == value {
476
472
return
477
473
}
478
- s .journal .append (transientStorageChange {
479
- account : & addr ,
480
- key : key ,
481
- prevalue : prev ,
482
- })
474
+ s .journal .JournalSetTransientState (addr , key , prev )
483
475
s .setTransientState (addr , key , value )
484
476
}
485
477
@@ -629,7 +621,7 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
629
621
prev = s .getDeletedStateObject (addr ) // Note, prev might have been deleted, we need that!
630
622
newobj = newObject (s , addr , nil )
631
623
if prev == nil {
632
- s .journal .append ( createObjectChange { account : & addr } )
624
+ s .journal .JournalCreate ( addr )
633
625
} else {
634
626
// The original account should be marked as destructed and all cached
635
627
// account and storage data should be cleared as well. Note, it must
@@ -643,16 +635,10 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
643
635
// will be called for each transaction before byzantium fork which will always
644
636
// cache the latest account/storage data.
645
637
prevAccount , ok := s .accountsOrigin [prev .address ]
646
- s .journal .append (resetObjectChange {
647
- account : & addr ,
648
- prev : prev ,
649
- prevdestruct : prevdestruct ,
650
- prevAccount : s .accounts [prev .addrHash ],
651
- prevStorage : s .storages [prev .addrHash ],
652
- prevAccountOriginExist : ok ,
653
- prevAccountOrigin : prevAccount ,
654
- prevStorageOrigin : s .storagesOrigin [prev .address ],
655
- })
638
+ s .journal .JournalReset (addr , prev , prevdestruct ,
639
+ s .accounts [prev .addrHash ], s .storages [prev .addrHash ], ok ,
640
+ prevAccount , s .storagesOrigin [prev .address ])
641
+
656
642
delete (s .accounts , prev .addrHash )
657
643
delete (s .storages , prev .addrHash )
658
644
delete (s .accountsOrigin , prev .address )
@@ -1342,7 +1328,7 @@ func (s *StateDB) Prepare(rules params.Rules, sender, coinbase common.Address, d
1342
1328
// AddAddressToAccessList adds the given address to the access list
1343
1329
func (s * StateDB ) AddAddressToAccessList (addr common.Address ) {
1344
1330
if s .accessList .AddAddress (addr ) {
1345
- s .journal .append ( accessListAddAccountChange { & addr } )
1331
+ s .journal .JournalAccessListAddAccount ( addr )
1346
1332
}
1347
1333
}
1348
1334
@@ -1354,13 +1340,10 @@ func (s *StateDB) AddSlotToAccessList(addr common.Address, slot common.Hash) {
1354
1340
// scope of 'address' without having the 'address' become already added
1355
1341
// to the access list (via call-variant, create, etc).
1356
1342
// Better safe than sorry, though
1357
- s .journal .append ( accessListAddAccountChange { & addr } )
1343
+ s .journal .JournalAccessListAddAccount ( addr )
1358
1344
}
1359
1345
if slotMod {
1360
- s .journal .append (accessListAddSlotChange {
1361
- address : & addr ,
1362
- slot : & slot ,
1363
- })
1346
+ s .journal .JournalAccessListAddSlot (addr , slot )
1364
1347
}
1365
1348
}
1366
1349
0 commit comments