chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit 1ea196d04b81a52b330abd8cc63cc4560330867b
parent cf1d4e4785fcd262fcac59a727ab39cb469936e5
Author: nolash <dev@holbrook.no>
Date:   Thu, 11 Feb 2021 12:46:36 +0100

Relax chainlib dep, bump version

Diffstat:
Mchainsyncer/driver.py | 21+++++++++++++--------
Mrequirements.txt | 2+-
Msetup.cfg | 2+-
3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/chainsyncer/driver.py b/chainsyncer/driver.py @@ -6,8 +6,8 @@ import time logg = logging.getLogger() -def noop_progress(s): - logg.debug(s) +def noop_progress(s, block_number, tx_index): + logg.debug('({},{}) {}'.format(block_number, tx_index, s)) class Syncer: @@ -44,11 +44,16 @@ class MinedSyncer(Syncer): def loop(self, interval, getter): while self.running and Syncer.running_global: + g = self.backend.get() + start_tx = g[1] + self.progress_callback('loop awakened', g[0], start_tx) while True: - block_hash = self.get(getter) - if block_hash == None: + block = self.get(getter) + if block == None: break - self.process(getter, block_hash) + self.process(getter, block) + self.progress_callback('process block {}'.format(self.backend.get()), block.number, start_tx) + start_tx = 0 time.sleep(self.yield_delay) time.sleep(interval) @@ -60,18 +65,18 @@ class HeadSyncer(MinedSyncer): def process(self, getter, block): - logg.debug('process {}'.format(block)) + logg.debug('process block {}'.format(block)) i = 0 tx = None while True: try: #self.filter[0].handle(getter, block, None) tx = block.tx(i) - self.progress_callback('processing {}'.format(tx)) + self.progress_callback('processing {}'.format(repr(tx)), block.number, i) self.backend.set(block.number, i) for f in self.filter: f.handle(getter, block, tx) - self.progress_callback('applied filter {} on {}'.format(f.name(), tx)) + self.progress_callback('applied filter {} on {}'.format(f.name(), repr(tx)), block.number, i) except IndexError as e: self.backend.set(block.number + 1, 0) break diff --git a/requirements.txt b/requirements.txt @@ -5,4 +5,4 @@ eth-tester==0.5.0b3 confini==0.3.6b2 semver==2.13.0 hexathon==0.0.1a2 -chainlib==0.0.1a5 +chainlib~=0.0.1a6 diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainsyncer -version = 0.0.1a3 +version = 0.0.1a4 description = Generic blockchain syncer driver author = Louis Holbrook author_email = dev@holbrook.no