From 5a6fe7327dc7dab8d8cabc94fa6a56136fc21a91 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 22 Feb 2021 22:22:25 +0100 Subject: [PATCH] Rehabilitate gas filter --- .../cic_eth/runnable/daemons/filters/callback.py | 3 +++ .../cic_eth/runnable/daemons/filters/gas.py | 11 +++++++---- .../cic_eth/runnable/daemons/filters/register.py | 5 +++++ .../cic-eth/cic_eth/runnable/daemons/filters/tx.py | 4 ++++ apps/cic-eth/cic_eth/runnable/daemons/manager.py | 14 ++++++++++---- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/apps/cic-eth/cic_eth/runnable/daemons/filters/callback.py b/apps/cic-eth/cic_eth/runnable/daemons/filters/callback.py index c70ddc72..ace3be58 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/filters/callback.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/filters/callback.py @@ -105,3 +105,6 @@ class CallbackFilter(SyncFilter): self.call_back(tokentx.to_dict()) except UnknownContractError: logg.debug('callback filter {}:{} skipping "transfer" method on unknown contract {} tx {}'.format(tc.queue, tc.method, transfer_data['to'], tx.hash.hex())) + + def __str__(self): + return 'cic-eth callbacks' diff --git a/apps/cic-eth/cic_eth/runnable/daemons/filters/gas.py b/apps/cic-eth/cic_eth/runnable/daemons/filters/gas.py index 3a44db8a..db6c9d31 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/filters/gas.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/filters/gas.py @@ -22,10 +22,9 @@ class GasFilter(SyncFilter): self.queue = queue - def filter(self, w3, tx, rcpt, chain_str, session=None): - logg.debug('applying gas filter') - tx_hash_hex = tx.hash.hex() - if tx['value'] > 0: + def filter(self, conn, block, tx, session): #rcpt, chain_str, session=None): + tx_hash_hex = tx.hash + if tx.value > 0: logg.debug('gas refill tx {}'.format(tx_hash_hex)) session = SessionBase.bind_session(session) q = session.query(TxCache.recipient) @@ -54,3 +53,7 @@ class GasFilter(SyncFilter): queue=self.queue, ) s.apply_async() + + + def __str__(self): + return 'eic-eth gasfilter' diff --git a/apps/cic-eth/cic_eth/runnable/daemons/filters/register.py b/apps/cic-eth/cic_eth/runnable/daemons/filters/register.py index f753d57f..03c80938 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/filters/register.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/filters/register.py @@ -37,3 +37,8 @@ class RegistrationFilter(SyncFilter): queue=self.queue, ) s.apply_async() + + + def __str__(self): + return 'cic-eth account registration' + diff --git a/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py b/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py index ceab9a10..93d6a5c9 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/filters/tx.py @@ -39,3 +39,7 @@ class TxFilter(SyncFilter): ) t = s.apply_async() return t + + + def __str__(self): + return 'cic-eth erc20 transfer filter' diff --git a/apps/cic-eth/cic_eth/runnable/daemons/manager.py b/apps/cic-eth/cic_eth/runnable/daemons/manager.py index be4cab9e..6a3974f0 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/manager.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/manager.py @@ -98,11 +98,17 @@ def main(): syncers = [] - if SyncerBackend.first(chain_spec): - backend = SyncerBackend.initial(chain_spec, block_offset) + #if SyncerBackend.first(chain_spec): + # backend = SyncerBackend.initial(chain_spec, block_offset) + syncer_backends = SyncerBackend.resume(chain_spec, block_offset) + + if len(syncer_backends) == 0: + syncer_backends.append(SyncerBackend.initial(chain_spec, block_offset)) + + #block_sync = SyncerBackend.live(chain_spec, block_offset+1) + for syncer_backend in syncer_backends: + syncers.append(HeadSyncer(syncer_backend)) - block_sync = SyncerBackend.live(chain_spec, block_offset+1) - syncers.append(HeadSyncer(block_sync)) trusted_addresses_src = config.get('CIC_TRUST_ADDRESS') if trusted_addresses_src == None: