mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-02 18:25:21 +00:00
interface: subscribe to headers in run_fetch_blocks
so that 'monitor_connection' is already running while waiting for first header
This commit is contained in:
parent
3ec0ceba3e
commit
825d7c2cbd
1 changed files with 4 additions and 4 deletions
|
@ -340,7 +340,6 @@ class Interface(PrintError):
|
|||
return conn, res['count']
|
||||
|
||||
async def open_session(self, sslc, exit_early):
|
||||
header_queue = asyncio.Queue()
|
||||
self.session = NotificationSession(self.host, self.port, ssl=sslc, proxy=self.proxy)
|
||||
async with self.session as session:
|
||||
try:
|
||||
|
@ -350,11 +349,10 @@ class Interface(PrintError):
|
|||
if exit_early:
|
||||
return
|
||||
self.print_error("connection established. version: {}".format(ver))
|
||||
await session.subscribe('blockchain.headers.subscribe', [], header_queue)
|
||||
|
||||
async with self.group as group:
|
||||
await group.spawn(self.ping())
|
||||
await group.spawn(self.run_fetch_blocks(header_queue))
|
||||
await group.spawn(self.run_fetch_blocks())
|
||||
await group.spawn(self.monitor_connection())
|
||||
# NOTE: group.__aexit__ will be called here; this is needed to notice exceptions in the group!
|
||||
|
||||
|
@ -373,7 +371,9 @@ class Interface(PrintError):
|
|||
self.fut.cancel()
|
||||
asyncio.get_event_loop().create_task(self.group.cancel_remaining())
|
||||
|
||||
async def run_fetch_blocks(self, header_queue):
|
||||
async def run_fetch_blocks(self):
|
||||
header_queue = asyncio.Queue()
|
||||
await self.session.subscribe('blockchain.headers.subscribe', [], header_queue)
|
||||
while True:
|
||||
self.network.notify('updated')
|
||||
item = await header_queue.get()
|
||||
|
|
Loading…
Add table
Reference in a new issue