Avoid double sync of history when caught up

This commit is contained in:
lash 2022-04-09 18:58:47 +00:00
parent b8cd6e256a
commit fd62ad7075
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 9 additions and 2 deletions

View File

@ -11,7 +11,7 @@ from chainsyncer.db.models.filter import BlockchainSyncFilter
from chainsyncer.db.models.base import SessionBase
from .base import Backend
logg = logging.getLogger().getChild(__name__)
logg = logging.getLogger(__name__)
class SQLBackend(Backend):
@ -267,7 +267,8 @@ class SQLBackend(Backend):
session.flush()
#if block_height != block_resume:
if highest_unsynced_block < block_resume:
logg.info('last live id {} {} {}'.format(last_live_id, highest_unsynced_block, block_resume))
if highest_unsynced_block <= block_resume:
q = session.query(BlockchainSyncFilter)
q = q.filter(BlockchainSyncFilter.chain_sync_id==last_live_id)

View File

@ -65,6 +65,12 @@ class BlockPollSyncer(Syncer):
:returns: See chainsyncer.backend.base.Backend.get
"""
(pair, fltr) = self.backend.get()
(target, fltr_target) = self.backend.target()
if target == pair[0]:
logg.info('syncer was done before it started: {}'.format(self))
raise SyncDone(target)
start_tx = pair[1]