Skip not local transaction in sync
This commit is contained in:
parent
8c2905b801
commit
d0dbaad1f2
@ -1,8 +1,14 @@
|
|||||||
|
# standard imports
|
||||||
|
import logging
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from chainlib.status import Status as TxStatus
|
from chainlib.status import Status as TxStatus
|
||||||
|
from chainsyncer.filter import SyncFilter
|
||||||
|
from chainqueue.error import NotLocalTxError
|
||||||
|
|
||||||
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
class StateFilter:
|
class StateFilter(SyncFilter):
|
||||||
|
|
||||||
def __init__(self, adapter, throttler=None):
|
def __init__(self, adapter, throttler=None):
|
||||||
self.adapter = adapter
|
self.adapter = adapter
|
||||||
@ -10,10 +16,16 @@ class StateFilter:
|
|||||||
|
|
||||||
|
|
||||||
def filter(self, conn, block, tx, session=None):
|
def filter(self, conn, block, tx, session=None):
|
||||||
cache_tx = self.adapter.get(tx.hash)
|
try:
|
||||||
|
cache_tx = self.adapter.get(tx.hash)
|
||||||
|
except NotLocalTxError:
|
||||||
|
logg.debug('skipping not local transaction {}'.format(tx.hash))
|
||||||
|
return False
|
||||||
if tx.status == TxStatus.SUCCESS:
|
if tx.status == TxStatus.SUCCESS:
|
||||||
self.adapter.succeed(block, tx)
|
self.adapter.succeed(block, tx)
|
||||||
else:
|
else:
|
||||||
self.adapter.fail(block, tx)
|
self.adapter.fail(block, tx)
|
||||||
if self.throttler != None:
|
if self.throttler != None:
|
||||||
self.throttler.dec(tx.hash)
|
self.throttler.dec(tx.hash)
|
||||||
|
|
||||||
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user