chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit 90d091edfd633a9c07634a7055cf4917fc0b699b
parent 2400084251f97ec739d65f81043b2d19f1f18ccf
Author: nolash <dev@holbrook.no>
Date:   Thu,  3 Jun 2021 13:54:49 +0200

Add base setup for sql backend

Diffstat:
Mchainsyncer/backend/sql.py | 11++++++++++-
Mchainsyncer/db/migrations/sqlalchemy.py | 4++--
Mchainsyncer/runnable/tracker.py | 2--
Mrequirements.txt | 2+-
Msetup.cfg | 4++--
5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/chainsyncer/backend/sql.py b/chainsyncer/backend/sql.py @@ -22,6 +22,9 @@ class SQLBackend(Backend): :param object_id: Unique id for the syncer session. :type object_id: number """ + + base = None + def __init__(self, chain_spec, object_id): super(SQLBackend, self).__init__() self.db_session = None @@ -33,6 +36,13 @@ class SQLBackend(Backend): self.disconnect() + @classmethod + def setup(cls, dsn, debug=False, *args, **kwargs): + if cls.base == None: + cls.base = SessionBase + cls.base.connect(dsn, debug=debug, pool_size=kwargs.get('pool_size', 0)) + + def connect(self): """Loads the state of the syncer session with the given id. """ @@ -264,7 +274,6 @@ class SQLBackend(Backend): :returns: "Live" syncer object :rtype: cic_eth.db.models.BlockchainSync """ - object_id = None session = SessionBase.create_session() o = BlockchainSync(str(chain_spec), block_height, 0, None) diff --git a/chainsyncer/db/migrations/sqlalchemy.py b/chainsyncer/db/migrations/sqlalchemy.py @@ -1,10 +1,10 @@ from alembic import op import sqlalchemy as sa -def chainsyncer_upgrade(major, minor, patch): +def chainsyncer_upgrade(major=0, minor=0, patch=1): r0_0_1_u() -def chainsyncer_downgrade(major, minor, patch): +def chainsyncer_downgrade(major=0, minor=0, patch=1): r0_0_1_d() def r0_0_1_u(): diff --git a/chainsyncer/runnable/tracker.py b/chainsyncer/runnable/tracker.py @@ -42,7 +42,6 @@ argparser = argparse.ArgumentParser(description='daemon that monitors transactio argparser.add_argument('-p', '--provider', dest='p', type=str, help='chain rpc provider address') argparser.add_argument('-c', type=str, default=config_dir, help='config root to use') argparser.add_argument('-i', '--chain-spec', type=str, dest='i', help='chain spec') -argparser.add_argument('--abi-dir', dest='abi_dir', type=str, help='Directory containing bytecode and abi') argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration') argparser.add_argument('--offset', type=int, help='block number to start sync') argparser.add_argument('-q', type=str, default='cic-eth', help='celery queue to submit transaction tasks to') @@ -56,7 +55,6 @@ elif args.vv == True: logging.getLogger().setLevel(logging.DEBUG) config_dir = os.path.join(args.c) -os.makedirs(config_dir, 0o777, True) config = confini.Config(config_dir, args.env_prefix) config.process() # override args diff --git a/requirements.txt b/requirements.txt @@ -1,4 +1,4 @@ confini~=0.3.6rc3 semver==2.13.0 hexathon~=0.0.1a7 -chainlib~=0.0.2a15 +chainlib~=0.0.3rc2 diff --git a/setup.cfg b/setup.cfg @@ -1,10 +1,10 @@ [metadata] name = chainsyncer -version = 0.0.2a3 +version = 0.0.2a5 description = Generic blockchain syncer driver author = Louis Holbrook author_email = dev@holbrook.no -url = https://gitlab.com/nolash/chainsyncer +url = https://gitlab.com/chaintools/chainsyncer keywords = cryptocurrency classifiers =