async def _hang_until_storage_served(self, event: CollectMissingStorage) -> None: try: await self.wait(self._serve_storage(event)) except OperationCancelled: await self._event_bus.broadcast( MissingStorageResult(is_retry_acceptable=False), event.broadcast_config(), ) raise
async def _serve_storage(self, event: CollectMissingStorage) -> None: await self._state_downloader.ensure_node_present( event.missing_node_hash) num_nodes_collected = await self._state_downloader.download_storage( event.storage_key, event.storage_root_hash, event.account_address, ) await self._event_bus.broadcast( MissingStorageCollected(num_nodes_collected), event.broadcast_config(), )
async def _hang_until_storage_served(self, event: CollectMissingStorage) -> None: try: await asyncio.wait_for( self._serve_storage(event), timeout=BLOCK_IMPORT_MISSING_STATE_TIMEOUT, ) except asyncio.CancelledError: await self._event_bus.broadcast( MissingStorageResult(is_retry_acceptable=False), event.broadcast_config(), ) raise except asyncio.TimeoutError: pass
async def _serve_storage(self, event: CollectMissingStorage) -> None: num_nodes_collected = await self._state_downloader.download_storage( event.storage_key, event.storage_root_hash, event.account_address, event.urgent, ) bonus_node = await self._state_downloader.ensure_nodes_present( {event.missing_node_hash}, event.urgent, ) await self._event_bus.broadcast( MissingStorageResult(num_nodes_collected + bonus_node), event.broadcast_config(), )
async def collect_storage(event: CollectMissingStorage): replace_missing_node(event.missing_node_hash) await event_bus.broadcast( MissingStorageResult(1), event.broadcast_config() )