mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
interface: split run_fetch_blocks
The 'continue' in the middle was too easy to miss. We want a 'network_updated' trigger from every interface, not just the fastest.
This commit is contained in:
parent
f9a5f2e183
commit
8ee1f140d8
1 changed files with 13 additions and 9 deletions
|
@ -385,17 +385,21 @@ class Interface(PrintError):
|
||||||
if self.tip < constants.net.max_checkpoint():
|
if self.tip < constants.net.max_checkpoint():
|
||||||
raise GracefulDisconnect('server tip below max checkpoint')
|
raise GracefulDisconnect('server tip below max checkpoint')
|
||||||
self.mark_ready()
|
self.mark_ready()
|
||||||
|
await self._process_header_at_tip()
|
||||||
|
self.network.trigger_callback('network_updated')
|
||||||
|
self.network.switch_lagging_interface()
|
||||||
|
|
||||||
|
async def _process_header_at_tip(self):
|
||||||
|
height, header = self.tip, self.tip_header
|
||||||
async with self.network.bhi_lock:
|
async with self.network.bhi_lock:
|
||||||
if self.blockchain.height() >= height and self.blockchain.check_header(header):
|
if self.blockchain.height() >= height and self.blockchain.check_header(header):
|
||||||
# another interface amended the blockchain
|
# another interface amended the blockchain
|
||||||
self.print_error("skipping header", height)
|
self.print_error("skipping header", height)
|
||||||
continue
|
return
|
||||||
_, height = await self.step(height, header)
|
_, height = await self.step(height, header)
|
||||||
# in the simple case, height == self.tip+1
|
# in the simple case, height == self.tip+1
|
||||||
if height <= self.tip:
|
if height <= self.tip:
|
||||||
await self.sync_until(height)
|
await self.sync_until(height)
|
||||||
self.network.trigger_callback('network_updated')
|
|
||||||
self.network.switch_lagging_interface()
|
|
||||||
|
|
||||||
async def sync_until(self, height, next_height=None):
|
async def sync_until(self, height, next_height=None):
|
||||||
if next_height is None:
|
if next_height is None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue