@@ -294,31 +294,29 @@ def add_transaction(self, transaction):
294
294
# if unsuccessful the prerequisites were not fullfilled
295
295
# and the tx is invalid, state must not have changed
296
296
log .debug ('invalid tx' , error = e )
297
- success = False
297
+ assert transaction not in self .get_transactions ()
298
+ head_candidate .state_root = old_state_root # reset
299
+ return False
300
+
301
+ log .debug ('valid tx' )
298
302
299
303
# we might have a new head_candidate (due to ctx switches in pyethapp)
300
304
if self .head_candidate != head_candidate :
301
305
log .debug ('head_candidate changed during validation, trying again' )
302
306
self .add_transaction (transaction )
303
307
return
304
308
305
- if success :
306
- assert transaction in self .get_transactions ()
307
- self .pre_finalize_state_root = head_candidate .state_root
308
- head_candidate .finalize ()
309
- log .debug ('tx applied' , result = output )
310
- assert old_state_root != head_candidate .state_root
311
- return True
312
- else :
313
- log .debug ('tx failed' )
314
- head_candidate .state_root = old_state_root # reset
315
- return False
309
+ assert transaction in self .get_transactions ()
310
+ self .pre_finalize_state_root = head_candidate .state_root
311
+ head_candidate .finalize ()
312
+ log .debug ('tx applied' , result = output )
313
+ assert old_state_root != head_candidate .state_root
314
+ return True
316
315
317
316
def get_transactions (self ):
318
317
"""Get a list of new transactions not yet included in a mined block
319
318
but known to the chain.
320
319
"""
321
- log .debug ("get_transactions called" )
322
320
if self .head_candidate :
323
321
return self .head_candidate .get_transactions ()
324
322
else :
0 commit comments