Rehabilitate all except straggler after removal of db_session in filter
This commit is contained in:
parent
38d5ca3826
commit
1de24f8436
|
@ -10,7 +10,7 @@ from chainqueue.sql.state import (
|
||||||
from chainqueue.error import TxStateChangeError
|
from chainqueue.error import TxStateChangeError
|
||||||
from hexathon import to_int as hex_to_int
|
from hexathon import to_int as hex_to_int
|
||||||
from chainlib.eth.gas import balance
|
from chainlib.eth.gas import balance
|
||||||
from chainqueue.sql.query import get_tx_cache
|
from cic_eth.queue.query import get_tx_cache_local
|
||||||
from chainqueue.enum import StatusBits
|
from chainqueue.enum import StatusBits
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
|
@ -24,7 +24,7 @@ class StragglerFilter(SyncFilter):
|
||||||
gas_balance_threshold = 0
|
gas_balance_threshold = 0
|
||||||
|
|
||||||
def filter(self, conn, block, tx):
|
def filter(self, conn, block, tx):
|
||||||
txc = get_tx_cache(self.chain_spec, tx.hash)
|
txc = get_tx_cache_local(self.chain_spec, tx.hash)
|
||||||
if txc['status_code'] & StatusBits.GAS_ISSUES > 0:
|
if txc['status_code'] & StatusBits.GAS_ISSUES > 0:
|
||||||
o = balance(tx.outputs[0])
|
o = balance(tx.outputs[0])
|
||||||
r = conn.do(o)
|
r = conn.do(o)
|
||||||
|
@ -46,7 +46,7 @@ class StragglerFilter(SyncFilter):
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
obsolete_by_cache(self.chain_spec, tx.hash, False, session=db_session)
|
obsolete_by_cache(self.chain_spec, tx.hash, False)
|
||||||
except TxStateChangeError:
|
except TxStateChangeError:
|
||||||
set_fubar(self.chain_spec, tx.hash, session=db_session)
|
set_fubar(self.chain_spec, tx.hash, session=db_session)
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -26,11 +26,9 @@ logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
class TransferAuthFilter(SyncFilter):
|
class TransferAuthFilter(SyncFilter):
|
||||||
|
|
||||||
def __init__(self, registry, chain_spec, conn, queue=None, call_address=ZERO_ADDRESS):
|
def __init__(self, chain_spec, registry, queue, caller_address=ZERO_ADDRESS):
|
||||||
self.queue = queue
|
super(TransferAuthFilter, self).__init__(chain_spec, registry, queue, caller_address=caller_address)
|
||||||
self.chain_spec = chain_spec
|
self.transfer_request_contract = registry.by_name('TransferAuthorization', sender_address=caller_address)
|
||||||
registry = CICRegistry(chain_spec, conn)
|
|
||||||
self.transfer_request_contract = registry.by_name('TransferAuthorization', sender_address=call_address)
|
|
||||||
|
|
||||||
|
|
||||||
def filter(self, conn, block, tx):
|
def filter(self, conn, block, tx):
|
||||||
|
|
|
@ -19,7 +19,7 @@ logg = logging.getLogger(__name__)
|
||||||
class TxFilter(SyncFilter):
|
class TxFilter(SyncFilter):
|
||||||
|
|
||||||
def filter(self, conn, block, tx):
|
def filter(self, conn, block, tx):
|
||||||
super(TxFilter, self).filter(conn, block)
|
super(TxFilter, self).filter(conn, block, tx)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
get_tx_local(self.chain_spec, tx.hash)
|
get_tx_local(self.chain_spec, tx.hash)
|
||||||
|
|
|
@ -17,6 +17,7 @@ from chainlib.eth.block import (
|
||||||
from hexathon import strip_0x
|
from hexathon import strip_0x
|
||||||
from chainqueue.sql.query import get_account_tx
|
from chainqueue.sql.query import get_account_tx
|
||||||
from cic_eth.encode import tx_normalize
|
from cic_eth.encode import tx_normalize
|
||||||
|
from cic_eth_registry import CICRegistry
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic_sync_filter.transferauth import TransferAuthFilter
|
from cic_sync_filter.transferauth import TransferAuthFilter
|
||||||
|
@ -61,7 +62,9 @@ def test_filter_transferauth(
|
||||||
tx_src = unpack(tx_signed_raw_bytes, default_chain_spec)
|
tx_src = unpack(tx_signed_raw_bytes, default_chain_spec)
|
||||||
tx = Tx(tx_src, block=block)
|
tx = Tx(tx_src, block=block)
|
||||||
|
|
||||||
fltr = TransferAuthFilter(cic_registry, default_chain_spec, eth_rpc, call_address=contract_roles['CONTRACT_DEPLOYER'])
|
registry = CICRegistry(default_chain_spec, eth_rpc)
|
||||||
|
queue = None
|
||||||
|
fltr = TransferAuthFilter(default_chain_spec, registry, queue, caller_address=contract_roles['CONTRACT_DEPLOYER'])
|
||||||
t = fltr.filter(eth_rpc, block, tx)
|
t = fltr.filter(eth_rpc, block, tx)
|
||||||
|
|
||||||
t.get_leaf()
|
t.get_leaf()
|
||||||
|
|
Loading…
Reference in New Issue