@@ -270,6 +270,10 @@ 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 .debug ('new tx' , num_txs = len (self .get_transactions ()), tx_hash = transaction )
274
+ if transaction in self .get_transactions ():
275
+ log .debug ('known tx' )
276
+ return
273
277
old_state_root = self .head_candidate .state_root
274
278
# revert finalization
275
279
self .head_candidate .state_root = self .pre_finalize_state_root
@@ -278,19 +282,18 @@ def add_transaction(self, transaction):
278
282
except processblock .InvalidTransaction as e :
279
283
# if unsuccessful the prerequisites were not fullfilled
280
284
# and the tx is invalid, state must not have changed
281
- log .debug ('invalid tx' , tx_hash = transaction , errors = e )
285
+ log .debug ('invalid tx' , error = e )
282
286
success = False
283
287
284
288
if success :
285
289
assert transaction in self .get_transactions ()
286
290
self .pre_finalize_state_root = self .head_candidate .state_root
287
291
self .head_candidate .finalize ()
288
- log .debug ('tx applied' , tx_hash = transaction ,
289
- block_hash = self .head_candidate , result = output )
292
+ log .debug ('tx applied' , result = output )
290
293
assert old_state_root != self .head_candidate .state_root
291
294
return True
292
295
else :
293
- log .debug ('tx not applied' , tx_hash = transaction )
296
+ log .debug ('tx failed' )
294
297
self .head_candidate .state_root = old_state_root # reset
295
298
return False
296
299
0 commit comments