Skip to content

Commit

Permalink
add try..except for read_header()
Browse files Browse the repository at this point in the history
  • Loading branch information
icodeface committed Dec 18, 2019
1 parent 0ef76cb commit 662d93d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions electrum/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,17 @@ def read_header(self, height: int, deserialize=True) -> Union[dict, bytes]:
if height > self.height():
return

conn = sqlite3.connect(self.path(), check_same_thread=False)
cursor = conn.cursor()
cursor.execute('SELECT data FROM header WHERE height=?', (height,))
result = cursor.fetchone()
cursor.close()
conn.close()
try:
conn = sqlite3.connect(self.path(), check_same_thread=False)
cursor = conn.cursor()
cursor.execute('SELECT data FROM header WHERE height=?', (height,))
result = cursor.fetchone()
cursor.close()
conn.close()
except BaseException as e:
self.logger.error(f'read_header error:{e}')
return

if not result or len(result) < 1:
self.logger.error(f'read_header {height}, {self.forkpoint}, {self.parent.get_id()}, {result}, {self.height()}')
self.update_size()
Expand Down

0 comments on commit 662d93d

Please sign in to comment.