chaind-eth

Queue server for ethereum
Log | Files | Refs | README | LICENSE

commit 49ff9a4b9940e1d8c0a3dcd7c5960d71166d4412
parent ccabbc8ecc4c67d9fa7c0816d3daa633ce273766
Author: nolash <dev@holbrook.no>
Date:   Thu,  3 Jun 2021 16:15:19 +0200

Avoid none overwrite of tx in filter

Diffstat:
Achaind_eth/filter.py | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/chaind_eth/filter.py b/chaind_eth/filter.py @@ -0,0 +1,27 @@ +# standard imports +import logging + +# external imports +from chainlib.status import Status +from chainqueue.sql.query import get_tx +from chainqueue.error import NotLocalTxError +from chainqueue.sql.state import set_final + +logg = logging.getLogger(__name__) + + +class StateFilter: + + def __init__(self, chain_spec): + self.chain_spec = chain_spec + + + def filter(self, conn, block, tx, session=None): + otx = None + try: + otx = get_tx(self.chain_spec, tx.hash, session=session) + except NotLocalTxError: + return False + logg.info('finalizing local tx {} with status {}'.format(tx.hash, tx.status)) + status = tx.status != Status.SUCCESS + set_final(self.chain_spec, tx.hash, block=block.number, tx_index=tx.index, fail=status, session=session)