Skip to content

Commit 6607574

Browse files
committed
Merge opentimestamps#37: Recover broken pipe
fcc251a recover broken pipe (Riccardo Casatta) Pull request description: While it's true we should rethink the thread opentimestamps#35, this work around is something better that what we have now... Tree-SHA512: 8e1d05212429373ed48674b6ba76a04ddf37c5fdc7c1226919a14102656872ba23f28a4a7bf5383615caf1a473952d618f46059fae2066a228111422cbf98de8
2 parents 60ca30c + fcc251a commit 6607574

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

otsserver/stamper.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,18 @@ def __do_bitcoin(self):
300300
self.pending_commitments.add(reorged_commitment_timestamp.msg)
301301

302302
# Check if this block contains any of the pending transactions
303-
304-
try:
305-
block = proxy.getblock(block_hash)
306-
except KeyError:
307-
# Must have been a reorg or something, return
308-
logging.error("Failed to get block")
309-
return
303+
block = None
304+
while block is None:
305+
try:
306+
block = proxy.getblock(block_hash)
307+
except KeyError:
308+
# Must have been a reorg or something, return
309+
logging.error("Failed to get block")
310+
return
311+
except BrokenPipeError:
312+
logging.error("BrokenPipeError to get block")
313+
time.sleep(5)
314+
proxy = bitcoin.rpc.Proxy()
310315

311316
# the following is an optimization, by pre computing the tx_id we rapidly check if our unconfirmed tx
312317
# is in the block

0 commit comments

Comments
 (0)