@@ -270,8 +270,6 @@ def add_transaction(self, transaction):
270
270
if the transaction was invalid
271
271
"""
272
272
assert self .head_candidate is not None
273
- _log = log .bind (tx_hash = transaction )
274
- _log .debug ("add transaction" )
275
273
old_state_root = self .head_candidate .state_root
276
274
# revert finalization
277
275
self .head_candidate .state_root = self .pre_finalize_state_root
@@ -283,20 +281,18 @@ def add_transaction(self, transaction):
283
281
log .debug ('invalid tx' , tx_hash = transaction , errors = e )
284
282
success = False
285
283
286
- # finalize
287
- self .pre_finalize_state_root = self .head_candidate .state_root
288
- self .head_candidate .finalize ()
289
-
290
- if not success :
291
- log .debug ('tx not applied' , tx_hash = transaction )
292
- assert old_state_root == self .head_candidate .state_root
293
- return False
294
- else :
284
+ if success :
295
285
assert transaction in self .get_transactions ()
296
- log .debug ('transaction applied' , tx_hash = transaction ,
286
+ self .pre_finalize_state_root = self .head_candidate .state_root
287
+ self .head_candidate .finalize ()
288
+ log .debug ('tx applied' , tx_hash = transaction ,
297
289
block_hash = self .head_candidate , result = output )
298
290
assert old_state_root != self .head_candidate .state_root
299
291
return True
292
+ else :
293
+ log .debug ('tx not applied' , tx_hash = transaction )
294
+ self .head_candidate .state_root = old_state_root # reset
295
+ return False
300
296
301
297
def get_transactions (self ):
302
298
"""Get a list of new transactions not yet included in a mined block
0 commit comments