mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
interface: try hard not to infinite loop while getting headers
This commit is contained in:
parent
da23e71db1
commit
3fc9326c43
1 changed files with 3 additions and 1 deletions
|
@ -400,6 +400,7 @@ class Interface(PrintError):
|
|||
next_height = self.tip
|
||||
last = None
|
||||
while last is None or height <= next_height:
|
||||
prev_last, prev_height = last, height
|
||||
if next_height > height + 10:
|
||||
could_connect, num_headers = await self.request_chunk(height, next_height)
|
||||
if not could_connect:
|
||||
|
@ -414,6 +415,7 @@ class Interface(PrintError):
|
|||
last = 'catchup'
|
||||
else:
|
||||
last, height = await self.step(height)
|
||||
assert (prev_last, prev_height) != (last, height), 'had to prevent infinite loop in interface.sync_until'
|
||||
return last, height
|
||||
|
||||
async def step(self, height, header=None):
|
||||
|
@ -422,7 +424,7 @@ class Interface(PrintError):
|
|||
if header is None:
|
||||
header = await self.get_block_header(height, 'catchup')
|
||||
chain = self.blockchain.check_header(header) if 'mock' not in header else header['mock']['check'](header)
|
||||
if chain: return 'catchup', height
|
||||
if chain: return 'catchup', height+1
|
||||
can_connect = blockchain.can_connect(header) if 'mock' not in header else header['mock']['connect'](height)
|
||||
|
||||
if not can_connect:
|
||||
|
|
Loading…
Add table
Reference in a new issue