handle es_info being an empty file

This commit is contained in:
Jack Robison 2022-09-20 15:58:12 -04:00
parent 04d747ff99
commit fc234b12e5

View file

@ -89,7 +89,10 @@ class ElasticSyncService(BlockchainReaderService):
info = {} info = {}
if os.path.exists(self._es_info_path): if os.path.exists(self._es_info_path):
with open(self._es_info_path, 'r') as f: with open(self._es_info_path, 'r') as f:
try:
info.update(json.loads(f.read())) info.update(json.loads(f.read()))
except json.decoder.JSONDecodeError:
self.log.warning('failed to parse es sync status file')
self._last_wrote_height = int(info.get('height', 0)) self._last_wrote_height = int(info.get('height', 0))
self._last_wrote_block_hash = info.get('block_hash', None) self._last_wrote_block_hash = info.get('block_hash', None)