Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 51ef2d1

Browse files
committed
fix: add_transaction / check for known
1 parent d24c4f2 commit 51ef2d1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ethereum/chain.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ def add_transaction(self, transaction):
270270
if the transaction was invalid
271271
"""
272272
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
273277
old_state_root = self.head_candidate.state_root
274278
# revert finalization
275279
self.head_candidate.state_root = self.pre_finalize_state_root
@@ -278,19 +282,18 @@ def add_transaction(self, transaction):
278282
except processblock.InvalidTransaction as e:
279283
# if unsuccessful the prerequisites were not fullfilled
280284
# 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)
282286
success = False
283287

284288
if success:
285289
assert transaction in self.get_transactions()
286290
self.pre_finalize_state_root = self.head_candidate.state_root
287291
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)
290293
assert old_state_root != self.head_candidate.state_root
291294
return True
292295
else:
293-
log.debug('tx not applied', tx_hash=transaction)
296+
log.debug('tx failed')
294297
self.head_candidate.state_root = old_state_root # reset
295298
return False
296299

0 commit comments

Comments
 (0)