chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit 7078adaf7ef7078c7f9bba3a01e6e1e0a0f41782
parent ecb123f49525756538048d5ee09eeaf572ee176d
Author: lash <dev@holbrook.no>
Date:   Tue, 29 Mar 2022 11:28:37 +0000

WIP implement sync done in resume sync for mock driver

Diffstat:
Mchainsyncer/driver.py | 4+++-
Mchainsyncer/unittest/base.py | 5++++-
Mtests/test_session.py | 4+++-
3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/chainsyncer/driver.py b/chainsyncer/driver.py @@ -110,7 +110,6 @@ class SyncDriver: if self.block_callback != None: self.block_callback(block, None) - last_block = block try: self.process(conn, item, block, tx_start) except IndexError: @@ -119,6 +118,9 @@ class SyncDriver: time.sleep(self.yield_delay) if self.post_callback != None: self.post_callback() + + if self.store.target > -1 and block.number >= self.store.target: + self.running = False self.idle(interval) diff --git a/chainsyncer/unittest/base.py b/chainsyncer/unittest/base.py @@ -195,7 +195,10 @@ class MockDriver(SyncDriver): def get(self, conn, item): - return self.blocks[item.cursor] + try: + return self.blocks[item.cursor] + except KeyError: + raise NoBlockForYou() def process(self, conn, item, block, tx_start): diff --git a/tests/test_session.py b/tests/test_session.py @@ -128,7 +128,9 @@ class TestFilter(unittest.TestCase): store = SyncFsStore(self.path, state_event_callback=state_event_handler, filter_state_event_callback=filter_state_event_handler) - drv = MockDriver(store) + fltr_one = MockFilter('foo') + store.register(fltr_one) + drv = MockDriver(store, target=1) generator.apply(drv, offset=1) drv.run(self.conn, interval=0.1)