Remove redundant postgres connections in backend resume method

This commit is contained in:
nolash 2021-02-23 08:46:14 +01:00
parent 9bd61f71bb
commit ea73d0082e
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
1 changed files with 6 additions and 1 deletions

View File

@ -199,11 +199,16 @@ class SyncerBackend:
o = q.get(object_id)
(highest_unsynced_block, highest_unsynced_index) = o.cursor()
for object_id in BlockchainSync.get_unsynced(session=session):
object_ids = BlockchainSync.get_unsynced(session=session)
session.close()
for object_id in object_ids:
logg.debug('block syncer resume added previously unsynced sync entry id {}'.format(object_id))
s = SyncerBackend(chain_spec, object_id)
syncers.append(s)
session = SessionBase.create_session()
last_live_id = BlockchainSync.get_last(session=session)
if last_live_id != None: