Skip to content

Commit

Permalink
fix(bridge_node.py): retry failed API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidLuckylee committed Mar 29, 2023
1 parent eda205a commit 2dc1359
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/headers_chain_proof/bridge_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def get_block_header(block_height):

url = f'https://blockstream.info/api/block/{ block_hash }'
r = http.request('GET', url)
tries = 0
while r.status != 200 and tries < 4:
print('ERROR: get_block_header received a bad answer from the API:',
r.status, r.data.decode('utf-8'))
# Try again
r = http_request('GET', url)
header = r.data.decode('utf-8')
return json.loads(header)

Expand Down

0 comments on commit 2dc1359

Please sign in to comment.