async def _serve_bytecode(self, event: CollectMissingBytecode) -> None: await self._state_downloader.ensure_nodes_present( {event.bytecode_hash}, event.block_number, event.urgent, ) await self._event_bus.broadcast(MissingBytecodeResult(), event.broadcast_config())
async def _provide_missing_bytecode(self) -> None: async for event in self._event_bus.stream(CollectMissingBytecode): if event.block_number >= self.minimum_beam_block_number: self.manager.run_task(self._hang_until_bytecode_served, event) else: await self._event_bus.broadcast( MissingBytecodeResult(is_retry_acceptable=False), event.broadcast_config(), )
async def _hang_until_bytecode_served(self, event: CollectMissingBytecode) -> None: try: await self.wait(self._serve_bytecode(event)) except OperationCancelled: await self._event_bus.broadcast( MissingBytecodeResult(is_retry_acceptable=False), event.broadcast_config(), ) raise
async def _hang_until_bytecode_served(self, event: CollectMissingBytecode) -> None: try: await asyncio.wait_for( self._serve_bytecode(event), timeout=BLOCK_IMPORT_MISSING_STATE_TIMEOUT, ) except asyncio.CancelledError: await self._event_bus.broadcast( MissingBytecodeResult(is_retry_acceptable=False), event.broadcast_config(), ) raise except asyncio.TimeoutError: pass
async def collect_bytecodes(event: CollectMissingBytecode): replace_missing_node(event.bytecode_hash) await event_bus.broadcast( MissingBytecodeResult(), event.broadcast_config() )