Loop runs!
This commit is contained in:
parent
66c0fd0b51
commit
c0e4ab5c2c
@ -2,8 +2,8 @@
|
||||
import logging
|
||||
|
||||
# local imports
|
||||
from cic_eth.db.models.sync import BlockchainSync
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_syncer.db.models.sync import BlockchainSync
|
||||
from cic_syncer.db.models.base import SessionBase
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
@ -21,7 +21,7 @@ class BlockchainSync(SessionBase):
|
||||
:param block_target: Block number to sync until, inclusive
|
||||
:type block_target: number
|
||||
"""
|
||||
__tablename__ = 'blockchain_sync'
|
||||
__tablename__ = 'chain_sync'
|
||||
|
||||
blockchain = Column(String)
|
||||
block_start = Column(Integer)
|
||||
|
@ -1,6 +1,7 @@
|
||||
# standard imports
|
||||
import uuid
|
||||
import logging
|
||||
import time
|
||||
|
||||
# third-party imports
|
||||
import websockets
|
||||
@ -10,6 +11,8 @@ logg = logging.getLogger()
|
||||
|
||||
class Syncer:
|
||||
|
||||
running_global = True
|
||||
|
||||
def __init__(self, backend):
|
||||
self.cursor = None
|
||||
self.running = True
|
||||
@ -30,7 +33,7 @@ class Syncer:
|
||||
class MinedSyncer(Syncer):
|
||||
|
||||
def __init__(self, backend):
|
||||
super(HeadSyncer, self).__init__(backend)
|
||||
super(MinedSyncer, self).__init__(backend)
|
||||
|
||||
|
||||
def loop(self, interval):
|
||||
@ -38,6 +41,7 @@ class MinedSyncer(Syncer):
|
||||
getter = self.backend.connect()
|
||||
logg.debug('loop execute')
|
||||
e = self.get(getter)
|
||||
time.sleep(interval)
|
||||
|
||||
|
||||
class HeadSyncer(MinedSyncer):
|
||||
|
@ -13,6 +13,8 @@ from cic_syncer.driver import HeadSyncer
|
||||
from cic_syncer.db import dsn_from_config
|
||||
from cic_syncer.db.models.base import SessionBase
|
||||
from cic_syncer.client.evm.websocket import EVMWebsocketClient
|
||||
from cic_syncer.backend import SyncerBackend
|
||||
from cic_syncer.error import LoopDone
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
@ -92,24 +94,15 @@ re_websocket = re.compile('^wss?://')
|
||||
re_http = re.compile('^https?://')
|
||||
c = EVMWebsocketClient(config.get('ETH_PROVIDER'))
|
||||
chain = args.i
|
||||
#blockchain_provider = config.get('ETH_PROVIDER')
|
||||
#if re.match(re_websocket, blockchain_provider) != None:
|
||||
# blockchain_provider = WebsocketProvider(blockchain_provider)
|
||||
#elif re.match(re_http, blockchain_provider) != None:
|
||||
# blockchain_provider = HTTPProvider(blockchain_provider)
|
||||
#else:
|
||||
# raise ValueError('unknown provider url {}'.format(blockchain_provider))
|
||||
#
|
||||
|
||||
|
||||
def main():
|
||||
#chain_spec = ChainSpec.from_chain_str(config.get('CIC_CHAIN_SPEC'))
|
||||
#c = RpcClient(chain_spec)
|
||||
|
||||
block_offset = c.block_number()
|
||||
logg.debug('block offset {}'.format(block_offset))
|
||||
|
||||
return
|
||||
syncer = SyncerBackend.live(chain, block_offset+1)
|
||||
syncer_backend = SyncerBackend.live(chain, block_offset+1)
|
||||
syncer = HeadSyncer(syncer_backend)
|
||||
|
||||
for cb in config.get('TASKS_SYNCER_CALLBACKS', '').split(','):
|
||||
task_split = cb.split(':')
|
||||
|
2
config/syncer.ini
Normal file
2
config/syncer.ini
Normal file
@ -0,0 +1,2 @@
|
||||
[syncer]
|
||||
loop_interval = 1
|
Loading…
Reference in New Issue
Block a user