chainsyncer

Blockchain syncer driver
Log | Files | Refs | LICENSE

commit f4c69365177d027a6f269667dd3cc00a3fe7c86c
parent 9758ade3d59aa5041de92f175ca819f0fff1f78b
Author: lash <dev@holbrook.no>
Date:   Sat,  2 Apr 2022 07:33:12 +0000

Detect done sync in store start function

Diffstat:
Mchainsyncer/store/fs.py | 27++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/chainsyncer/store/fs.py b/chainsyncer/store/fs.py @@ -241,17 +241,26 @@ class SyncFsStore: logg.info('added existing {}'.format(o)) fp = os.path.join(self.session_path, 'target') - if len(thresholds) == 0: - logg.info('syncer first run target {}'.format(target)) - self.first = True - f = open(fp, 'w') - f.write(str(target)) + have_target = False + try: + f = open(fp, 'r') + v = f.read() f.close() + self.target = int(v) + have_target = True + except FileNotFoundError as e: + pass - f = open(fp, 'r') - v = f.read() - f.close() - self.target = int(v) + if len(thresholds) == 0: + if have_target: + logg.warning('sync "{}" is already done, nothing to do'.format(self.session_id)) + else: + logg.info('syncer first run target {}'.format(target)) + self.first = True + f = open(fp, 'w') + f.write(str(target)) + f.close() + self.target = target def start(self, offset=0, target=-1):