chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit 88870dc12d11d4ca271b01cb48cb9fffa4e5f09c
parent 7d5ceb9a2855c5c9dbb98e1a635a8e14c20a1d8a
Author: lash <dev@holbrook.no>
Date:   Fri, 13 May 2022 07:12:27 +0000

Implement chainlib 0.3.0 structure

Diffstat:
Achainsyncer/__init__.py | 1+
Mchainsyncer/settings.py | 84++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mrequirements.txt | 6+++---
Msetup.cfg | 3++-
4 files changed, 48 insertions(+), 46 deletions(-)

diff --git a/chainsyncer/__init__.py b/chainsyncer/__init__.py @@ -0,0 +1 @@ +from .filter import SyncFilter diff --git a/chainsyncer/settings.py b/chainsyncer/settings.py @@ -11,45 +11,45 @@ from chainlib.settings import ChainSettings logg = logging.getLogger(__name__) -class ChainsyncerSettings(ChainSettings): - - def process_sync_backend(self, config): - self.o['SYNCER_BACKEND'] = config.get('SYNCER_BACKEND') - - - def process_sync_range(self, config): - o = self.o['SYNCER_INTERFACE'].block_latest() - r = self.o['RPC'].do(o) - block_offset = int(strip_0x(r), 16) + 1 - logg.info('network block height at startup is {}'.format(block_offset)) - - keep_alive = False - session_block_offset = 0 - block_limit = 0 - until = 0 - - if config.true('_HEAD'): - self.o['SYNCER_OFFSET'] = block_offset - self.o['SYNCER_LIMIT'] = -1 - return - - session_block_offset = int(config.get('SYNCER_OFFSET')) - until = int(config.get('SYNCER_LIMIT')) - - if until > 0: - if until <= session_block_offset: - raise ValueError('sync termination block number must be later than offset ({} >= {})'.format(session_block_offset, until)) - block_limit = until - elif until == -1: - keep_alive = True - - if session_block_offset == -1: - session_block_offset = block_offset - elif config.true('_KEEP_ALIVE'): - block_limit = -1 - else: - if block_limit == 0: - block_limit = block_offset - - self.o['SYNCER_OFFSET'] = session_block_offset - self.o['SYNCER_LIMIT'] = block_limit +def process_sync_backend(settings, config): + settings.set('SYNCER_BACKEND', config.get('SYNCER_BACKEND')) + return settings + + +def process_sync_range(settings, config): + o = settings.get('SYNCER_INTERFACE').block_latest() + r = settings.get('CONN').do(o) + block_offset = int(strip_0x(r), 16) + 1 + logg.info('network block height at startup is {}'.format(block_offset)) + + keep_alive = False + session_block_offset = 0 + block_limit = 0 + until = 0 + + if config.true('_HEAD'): + settings.set('SYNCER_OFFSET', block_offset) + settings.set('SYNCER_LIMIT', -1) + return settings + + session_block_offset = int(config.get('SYNCER_OFFSET')) + until = int(config.get('SYNCER_LIMIT')) + + if until > 0: + if until <= session_block_offset: + raise ValueError('sync termination block number must be later than offset ({} >= {})'.format(session_block_offset, until)) + block_limit = until + elif until == -1: + keep_alive = True + + if session_block_offset == -1: + session_block_offset = block_offset + elif config.true('_KEEP_ALIVE'): + block_limit = -1 + else: + if block_limit == 0: + block_limit = block_offset + + settings.set('SYNCER_OFFSET', session_block_offset) + settings.set('SYNCER_LIMIT', block_limit) + return settings diff --git a/requirements.txt b/requirements.txt @@ -1,5 +1,5 @@ -confini~=0.6.0 +confini~=0.6.1 semver==2.13.0 -hexathon~=0.1.6 -chainlib~=0.2.0 +hexathon~=0.1.7 +chainlib~=0.3.0 shep~=0.2.9 diff --git a/setup.cfg b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = chainsyncer -version = 0.4.10 +version = 0.4.11 description = Generic blockchain syncer driver author = Louis Holbrook author_email = dev@holbrook.no @@ -30,6 +30,7 @@ packages = chainsyncer.store chainsyncer.cli chainsyncer.runnable + chainsyncer.data #[options.package_data] #* =