예제 #1
0
 async def _provide_missing_account_tries(self) -> None:
     async for event in self._event_bus.stream(CollectMissingAccount):
         # If a request is coming in from an import on a block that's too old, cancel it
         if event.block_number >= self.minimum_beam_block_number:
             self.manager.run_task(self._hang_until_account_served, event)
         else:
             await self._event_bus.broadcast(
                 MissingAccountResult(is_retry_acceptable=False),
                 event.broadcast_config(),
             )
예제 #2
0
 async def _hang_until_account_served(self, event: CollectMissingAccount) -> None:
     try:
         await self.wait(self._serve_account(event))
     except OperationCancelled:
         # Beam sync is shutting down, probably either because the node is closing, or
         #   a pivot is required. So communicate that import should stop.
         await self._event_bus.broadcast(
             MissingAccountResult(is_retry_acceptable=False),
             event.broadcast_config(),
         )
         raise
예제 #3
0
 async def _serve_account(self, event: CollectMissingAccount) -> None:
     _, num_nodes_collected = await self._state_downloader.download_account(
         event.address_hash,
         event.state_root_hash,
         event.urgent,
     )
     bonus_node = await self._state_downloader.ensure_nodes_present(
         {event.missing_node_hash},
         event.urgent,
     )
     await self._event_bus.broadcast(
         MissingAccountResult(num_nodes_collected + bonus_node),
         event.broadcast_config(),
     )
예제 #4
0
파일: chain.py 프로젝트: Elnaril/trinity
 async def _hang_until_account_served(self, event: CollectMissingAccount) -> None:
     try:
         await asyncio.wait_for(
             self._serve_account(event),
             timeout=BLOCK_IMPORT_MISSING_STATE_TIMEOUT,
         )
     except asyncio.CancelledError:
         # Beam sync is shutting down, probably either because the node is closing, or
         #   a pivot is required. So communicate that import should stop.
         await self._event_bus.broadcast(
             MissingAccountResult(is_retry_acceptable=False),
             event.broadcast_config(),
         )
         raise
     except asyncio.TimeoutError:
         pass
예제 #5
0
 async def collect_accounts(event: CollectMissingAccount):
     replace_missing_node(event.missing_node_hash)
     await event_bus.broadcast(
         MissingAccountResult(1), event.broadcast_config()
     )