diff --git a/p2p/DEVELOPMENT.md b/p2p/DEVELOPMENT.md index 06f847b71d..76808980f0 100644 --- a/p2p/DEVELOPMENT.md +++ b/p2p/DEVELOPMENT.md @@ -26,7 +26,7 @@ library. ```Python class Node(BaseService): - async def _run(self): + async def do_run(self): self.discovery = DiscoveryService(token=self.cancel_token) self.run_daemon(self.discovery) self.run_task(self.discovery.bootstrap()) diff --git a/p2p/discovery.py b/p2p/discovery.py index a750d48152..93f604c473 100644 --- a/p2p/discovery.py +++ b/p2p/discovery.py @@ -956,7 +956,7 @@ def __init__(self, proto: DiscoveryProtocol, peer_pool: BasePeerPool, self.port = port self._lookup_running = asyncio.Lock() - async def _run(self) -> None: + async def do_run(self) -> None: await self._start_udp_listener() connect_loop_sleep = 2 self.run_task(self.proto.bootstrap()) @@ -1004,7 +1004,7 @@ async def maybe_lookup_random_node(self) -> None: finally: self._last_lookup = time.time() - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: await self.proto.stop() diff --git a/p2p/nat.py b/p2p/nat.py index 072d5b5c55..6256ab881a 100644 --- a/p2p/nat.py +++ b/p2p/nat.py @@ -69,7 +69,7 @@ def __init__(self, port: int, token: CancelToken = None) -> None: self.port = port self._mapping: PortMapping = None # when called externally, this never returns None - async def _run(self) -> None: + async def do_run(self) -> None: """Run an infinite loop refreshing our NAT port mapping. On every iteration we configure the port mapping with a lifetime of 30 minutes and then @@ -85,7 +85,7 @@ async def _run(self) -> None: except Exception: self.logger.exception("Failed to setup NAT portmap") - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: pass async def add_nat_portmap(self) -> str: diff --git a/p2p/peer.py b/p2p/peer.py index 19b07b96c3..cdbd4d6b3d 100644 --- a/p2p/peer.py +++ b/p2p/peer.py @@ -150,7 +150,7 @@ def __init__(self, peer: 'BasePeer') -> None: super().__init__(peer.cancel_token) self.peer = peer - async def _run(self) -> None: + async def do_run(self) -> None: pass @@ -351,10 +351,10 @@ def close(self) -> None: def is_closing(self) -> bool: return self.writer.transport.is_closing() - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: self.close() - async def _run(self) -> None: + async def do_run(self) -> None: # The `boot` process is run in the background to allow the `run` loop # to continue so that all of the Peer APIs can be used within the # `boot` task. @@ -860,7 +860,7 @@ def _add_peer(self, for msg in msgs: subscriber.add_msg(msg) - async def _run(self) -> None: + async def do_run(self) -> None: # FIXME: PeerPool should probably no longer be a BaseService, but for now we're keeping it # so in order to ensure we cancel all peers when we terminate. if self.event_bus is not None: @@ -875,7 +875,7 @@ async def stop_all_peers(self) -> None: peer.disconnect(DisconnectReason.client_quitting) for peer in peers if peer.is_running ]) - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: await self.stop_all_peers() async def connect(self, remote: Node) -> BasePeer: diff --git a/p2p/service.py b/p2p/service.py index 7183699645..6d4c0d673b 100644 --- a/p2p/service.py +++ b/p2p/service.py @@ -84,9 +84,9 @@ def get_event_loop(self) -> asyncio.AbstractEventLoop: async def run( self, finished_callback: Optional[Callable[['BaseService'], None]] = None) -> None: - """Await for the service's _run() coroutine. + """Await for the service's do_run() coroutine. - Once _run() returns, triggers the cancel token, call cleanup() and + Once do_run() returns, triggers the cancel token, call cleanup() and finished_callback (if one was passed). """ if self.is_running: @@ -100,7 +100,7 @@ async def run( try: async with self._run_lock: self.events.started.set() - await self._run() + await self.do_run() except OperationCancelled as e: self.logger.debug("%s finished: %s", self, e) except Exception: @@ -236,10 +236,10 @@ async def _run_in_executor(self, callback: Callable[..., Any], *args: Any) -> An async def cleanup(self) -> None: """ - Run the ``_cleanup()`` coroutine and set the ``cleaned_up`` event after the service as + Run the ``do_cleanup()`` coroutine and set the ``cleaned_up`` event after the service as well as all child services finished their cleanup. - The ``_cleanup()`` coroutine is invoked before the child services may have finished + The ``do_cleanup()`` coroutine is invoked before the child services may have finished their cleanup. """ if self._child_services: @@ -253,7 +253,7 @@ async def cleanup(self) -> None: await asyncio.gather(*self._tasks) self.logger.debug("All tasks finished") - await self._cleanup() + await self.do_cleanup() self.events.cleaned_up.set() def cancel_nowait(self) -> None: @@ -322,17 +322,17 @@ async def sleep(self, delay: float) -> None: await self.wait(asyncio.sleep(delay)) @abstractmethod - async def _run(self) -> None: + async def do_run(self) -> None: """Run the service's loop. Should return or raise OperationCancelled when the CancelToken is triggered. """ raise NotImplementedError() - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: """Clean up any resources held by this service. - Called after the service's _run() method returns. + Called after the service's do_run() method returns. """ pass @@ -357,8 +357,8 @@ async def wrapped(service: BaseService, *args: Any, **kwargs: Any) -> Any: class EmptyService(BaseService): - async def _run(self) -> None: + async def do_run(self) -> None: pass - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: pass diff --git a/tests/p2p/test_service.py b/tests/p2p/test_service.py index 4e1a3c8841..469168c447 100644 --- a/tests/p2p/test_service.py +++ b/tests/p2p/test_service.py @@ -10,7 +10,7 @@ class ParentService(BaseService): be triggered. """ - async def _run(self): + async def do_run(self): self.daemon = WaitService(token=self.cancel_token) self.run_daemon(self.daemon) await self.cancel_token.wait() @@ -18,7 +18,7 @@ async def _run(self): class WaitService(BaseService): - async def _run(self): + async def do_run(self): await self.cancel_token.wait() diff --git a/tests/trinity/core/peer_helpers.py b/tests/trinity/core/peer_helpers.py index a2839e51ff..bdbe3c5285 100644 --- a/tests/trinity/core/peer_helpers.py +++ b/tests/trinity/core/peer_helpers.py @@ -130,5 +130,5 @@ def __init__(self, peers) -> None: for peer in peers: self.connected_nodes[peer.remote] = peer - async def _run(self) -> None: - raise NotImplementedError("This is a mock PeerPool implementation, you must not _run() it") + async def do_run(self) -> None: + raise NotImplementedError("This is a mock PeerPool implementation, you must not run it") diff --git a/trinity/extensibility/plugin.py b/trinity/extensibility/plugin.py index b4698a697a..f5973d6940 100644 --- a/trinity/extensibility/plugin.py +++ b/trinity/extensibility/plugin.py @@ -163,18 +163,18 @@ def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAct def start(self) -> None: """ - Delegate to :meth:`~trinity.extensibility.plugin.BasePlugin._start` and set ``running`` + Delegate to :meth:`~trinity.extensibility.plugin.BasePlugin.do_start` and set ``running`` to ``True``. Broadcast a :class:`~trinity.extensibility.events.PluginStartedEvent` on the :class:`~lahja.eventbus.EventBus` and hence allow other plugins to act accordingly. """ self.running = True - self._start() + self.do_start() self.event_bus.broadcast( PluginStartedEvent(type(self)) ) self.logger.info("Plugin started: %s", self.name) - def _start(self) -> None: + def do_start(self) -> None: """ Perform the actual plugin start routine. In the case of a `BaseIsolatedPlugin` this method will be called in a separate process. @@ -190,7 +190,7 @@ class BaseSyncStopPlugin(BasePlugin): A :class:`~trinity.extensibility.plugin.BaseSyncStopPlugin` unwinds synchronoulsy, hence blocks until the shutdown is done. """ - def _stop(self) -> None: + def do_stop(self) -> None: """ Stop the plugin. Should be overwritten by subclasses. """ @@ -198,10 +198,10 @@ def _stop(self) -> None: def stop(self) -> None: """ - Delegate to :meth:`~trinity.extensibility.plugin.BaseSyncStopPlugin._stop` causing the + Delegate to :meth:`~trinity.extensibility.plugin.BaseSyncStopPlugin.do_stop` causing the plugin to stop and setting ``running`` to ``False``. """ - self._stop() + self.do_stop() self.running = False @@ -211,7 +211,7 @@ class BaseAsyncStopPlugin(BasePlugin): needs to be awaited. """ - async def _stop(self) -> None: + async def do_stop(self) -> None: """ Asynchronously stop the plugin. Should be overwritten by subclasses. """ @@ -219,10 +219,10 @@ async def _stop(self) -> None: async def stop(self) -> None: """ - Delegate to :meth:`~trinity.extensibility.plugin.BaseAsyncStopPlugin._stop` causing the + Delegate to :meth:`~trinity.extensibility.plugin.BaseAsyncStopPlugin.do_stop` causing the plugin to stop asynchronously and setting ``running`` to ``False``. """ - await self._stop() + await self.do_stop() self.running = False @@ -250,7 +250,7 @@ class BaseIsolatedPlugin(BaseSyncStopPlugin): def start(self) -> None: """ - Prepare the plugin to get started and eventually call ``_start`` in a separate process. + Prepare the plugin to get started and eventually call ``do_start`` in a separate process. """ self.running = True self._process = ctx.Process( @@ -268,9 +268,9 @@ def _prepare_start(self) -> None: self.event_bus.broadcast( PluginStartedEvent(type(self)) ) - self._start() + self.do_start() - def _stop(self) -> None: + def do_stop(self) -> None: self.context.event_bus.stop() kill_process_gracefully(self._process, self.logger) @@ -290,7 +290,7 @@ def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAct def handle_event(self, activation_event: BaseEvent) -> None: self.logger.info("Debug plugin: handle_event called: %s", activation_event) - def _start(self) -> None: + def do_start(self) -> None: self.logger.info("Debug plugin: start called") asyncio.ensure_future(self.count_forever()) @@ -301,5 +301,5 @@ async def count_forever(self) -> None: i += 1 await asyncio.sleep(1) - async def _stop(self) -> None: + async def do_stop(self) -> None: self.logger.info("Debug plugin: stop called") diff --git a/trinity/nodes/base.py b/trinity/nodes/base.py index 96e661b97b..9531f0c88a 100644 --- a/trinity/nodes/base.py +++ b/trinity/nodes/base.py @@ -123,7 +123,7 @@ def notify_resource_available(self) -> None: BroadcastConfig(internal=True), ) - async def _run(self) -> None: + async def do_run(self) -> None: await self.event_bus.wait_for_connection() self.notify_resource_available() self.run_daemon_task(self.handle_network_id_requests()) diff --git a/trinity/nodes/light.py b/trinity/nodes/light.py index 270fc87f98..ec2765a0ec 100644 --- a/trinity/nodes/light.py +++ b/trinity/nodes/light.py @@ -47,9 +47,9 @@ def __init__(self, event_bus: Endpoint, trinity_config: TrinityConfig) -> None: token=self.cancel_token, ) - async def _run(self) -> None: + async def do_run(self) -> None: self.run_daemon(self._peer_chain) - await super()._run() + await super().do_run() def get_chain(self) -> LightDispatchChain: if self._chain is None: diff --git a/trinity/plugins/builtin/ethstats/ethstats_client.py b/trinity/plugins/builtin/ethstats/ethstats_client.py index b465b8cc8d..2b94231c8e 100644 --- a/trinity/plugins/builtin/ethstats/ethstats_client.py +++ b/trinity/plugins/builtin/ethstats/ethstats_client.py @@ -46,7 +46,7 @@ def __init__( self.send_queue: asyncio.Queue[EthstatsMessage] = asyncio.Queue() self.recv_queue: asyncio.Queue[EthstatsMessage] = asyncio.Queue() - async def _run(self) -> None: + async def do_run(self) -> None: await self.wait_first( self.send_handler(), self.recv_handler(), diff --git a/trinity/plugins/builtin/ethstats/ethstats_service.py b/trinity/plugins/builtin/ethstats/ethstats_service.py index a3ab3a6e65..4da2109aec 100644 --- a/trinity/plugins/builtin/ethstats/ethstats_service.py +++ b/trinity/plugins/builtin/ethstats/ethstats_service.py @@ -61,7 +61,7 @@ def __init__( self.chain = self.get_chain() - async def _run(self) -> None: + async def do_run(self) -> None: while self.is_operational: try: self.logger.info('Connecting to %s...' % self.server_url) diff --git a/trinity/plugins/builtin/ethstats/plugin.py b/trinity/plugins/builtin/ethstats/plugin.py index a3344ee65f..3b97435018 100644 --- a/trinity/plugins/builtin/ethstats/plugin.py +++ b/trinity/plugins/builtin/ethstats/plugin.py @@ -103,7 +103,7 @@ def ready(self) -> None: self.start() - def _start(self) -> None: + def do_start(self) -> None: service = EthstatsService( self.context, self.server_url, diff --git a/trinity/plugins/builtin/json_rpc/plugin.py b/trinity/plugins/builtin/json_rpc/plugin.py index e1e6bfd6e3..adf9f5b0ea 100644 --- a/trinity/plugins/builtin/json_rpc/plugin.py +++ b/trinity/plugins/builtin/json_rpc/plugin.py @@ -44,7 +44,7 @@ def configure_parser(self, arg_parser: ArgumentParser, subparser: _SubParsersAct help="Disables the JSON-RPC Server", ) - def _start(self) -> None: + def do_start(self) -> None: db_manager = create_db_manager(self.context.trinity_config.database_ipc_path) db_manager.connect() diff --git a/trinity/plugins/builtin/light_peer_chain_bridge/light_peer_chain_bridge.py b/trinity/plugins/builtin/light_peer_chain_bridge/light_peer_chain_bridge.py index 0475aa1dc2..af107939c4 100644 --- a/trinity/plugins/builtin/light_peer_chain_bridge/light_peer_chain_bridge.py +++ b/trinity/plugins/builtin/light_peer_chain_bridge/light_peer_chain_bridge.py @@ -150,7 +150,7 @@ def __init__(self, self.chain = chain self.event_bus = event_bus - async def _run(self) -> None: + async def do_run(self) -> None: self.logger.info("Running LightPeerChainEventBusHandler") self.run_daemon_task(self.handle_get_blockheader_by_hash_requests()) diff --git a/trinity/plugins/builtin/light_peer_chain_bridge/plugin.py b/trinity/plugins/builtin/light_peer_chain_bridge/plugin.py index ad0b900a2b..93221e57e9 100644 --- a/trinity/plugins/builtin/light_peer_chain_bridge/plugin.py +++ b/trinity/plugins/builtin/light_peer_chain_bridge/plugin.py @@ -57,12 +57,12 @@ def handle_event(self, event: ResourceAvailableEvent) -> None: self.chain = event.resource self.start() - def _start(self) -> None: + def do_start(self) -> None: chain = cast(LightDispatchChain, self.chain) self.handler = LightPeerChainEventBusHandler(chain._peer_chain, self.context.event_bus) asyncio.ensure_future(self.handler.run()) - async def _stop(self) -> None: + async def do_stop(self) -> None: # This isn't really needed for the standard shutdown case as the LightPeerChain will # automatically shutdown whenever the `CancelToken` it was chained with is triggered. # It may still be useful to stop the LightPeerChain Bridge plugin individually though. diff --git a/trinity/plugins/builtin/tx_pool/plugin.py b/trinity/plugins/builtin/tx_pool/plugin.py index f611eb6d3c..b6285b97dd 100644 --- a/trinity/plugins/builtin/tx_pool/plugin.py +++ b/trinity/plugins/builtin/tx_pool/plugin.py @@ -78,7 +78,7 @@ def handle_event(self, event: ResourceAvailableEvent) -> None: if all((self.peer_pool is not None, self.chain is not None, self.is_enabled)): self.start() - def _start(self) -> None: + def do_start(self) -> None: if isinstance(self.chain, BaseMainnetChain): validator = DefaultTransactionValidator(self.chain, BYZANTIUM_MAINNET_BLOCK) elif isinstance(self.chain, BaseRopstenChain): @@ -91,7 +91,7 @@ def _start(self) -> None: self.tx_pool = TxPool(self.peer_pool, validator, self.cancel_token) asyncio.ensure_future(self.tx_pool.run()) - async def _stop(self) -> None: + async def do_stop(self) -> None: # This isn't really needed for the standard shutdown case as the TxPool will automatically # shutdown whenever the `CancelToken` it was chained with is triggered. It may still be # useful to stop the TxPool plugin individually though. diff --git a/trinity/plugins/builtin/tx_pool/pool.py b/trinity/plugins/builtin/tx_pool/pool.py index de961061a0..95296eccda 100644 --- a/trinity/plugins/builtin/tx_pool/pool.py +++ b/trinity/plugins/builtin/tx_pool/pool.py @@ -67,7 +67,7 @@ def __init__(self, # now. msg_queue_maxsize: int = 2000 - async def _run(self) -> None: + async def do_run(self) -> None: self.logger.info("Running Tx Pool") with self.subscribe(self._peer_pool): @@ -122,5 +122,5 @@ def _add_txs_to_bloom(self, peer: ETHPeer, txs: Iterable[BaseTransactionFields]) for val in txs: self._bloom.add(self._construct_bloom_entry(peer, val)) - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: self.logger.info("Stopping Tx Pool...") diff --git a/trinity/protocol/common/boot.py b/trinity/protocol/common/boot.py index 0f6c95a09b..5693f4a80b 100644 --- a/trinity/protocol/common/boot.py +++ b/trinity/protocol/common/boot.py @@ -19,7 +19,7 @@ class DAOCheckBootManager(BasePeerBootManager): peer: 'BaseChainPeer' - async def _run(self) -> None: + async def do_run(self) -> None: try: await self.ensure_same_side_on_dao_fork() except DAOForkCheckFailure as err: diff --git a/trinity/protocol/common/managers.py b/trinity/protocol/common/managers.py index 944fbfa0cd..57b93a3de8 100644 --- a/trinity/protocol/common/managers.py +++ b/trinity/protocol/common/managers.py @@ -118,7 +118,7 @@ def complete_request(self) -> None: # # Service API # - async def _run(self) -> None: + async def do_run(self) -> None: self.logger.debug("Launching %r", self) with self.subscribe_peer(self._peer): @@ -176,7 +176,7 @@ def _request(self, request: BaseRequest[TRequestPayload]) -> None: def _is_pending(self) -> bool: return self.pending_request is not None - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: if self.pending_request is not None: self.logger.debug("Stream %r shutting down, cancelling the pending request", self) _, future = self.pending_request diff --git a/trinity/protocol/common/monitors.py b/trinity/protocol/common/monitors.py index f447646bb9..24bf9f8c89 100644 --- a/trinity/protocol/common/monitors.py +++ b/trinity/protocol/common/monitors.py @@ -75,7 +75,7 @@ def _notify_tip(self) -> None: for new_tip_event in self._subscriber_notices: new_tip_event.set() - async def _run(self) -> None: + async def do_run(self) -> None: self.run_daemon_task(self._handle_msg_loop()) with self.subscribe(self._peer_pool): await self.wait(self.events.cancelled.wait()) diff --git a/trinity/protocol/common/servers.py b/trinity/protocol/common/servers.py index 0a4b3bbe58..b6addfa484 100644 --- a/trinity/protocol/common/servers.py +++ b/trinity/protocol/common/servers.py @@ -47,7 +47,7 @@ def __init__( super().__init__(token) self._peer_pool = peer_pool - async def _run(self) -> None: + async def do_run(self) -> None: self.run_daemon_task(self._handle_msg_loop()) with self.subscribe(self._peer_pool): await self.events.cancelled.wait() diff --git a/trinity/rpc/ipc.py b/trinity/rpc/ipc.py index 576d2bd475..dfd190623d 100644 --- a/trinity/rpc/ipc.py +++ b/trinity/rpc/ipc.py @@ -140,7 +140,7 @@ def __init__( self.rpc = rpc self.ipc_path = ipc_path - async def _run(self) -> None: + async def do_run(self) -> None: self.server = await asyncio.start_unix_server( connection_handler(self.rpc.execute, self.cancel_token), str(self.ipc_path), @@ -150,7 +150,7 @@ async def _run(self) -> None: self.logger.info('IPC started at: %s', self.ipc_path.resolve()) await self.cancel_token.wait() - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: self.server.close() await self.server.wait_closed() self.ipc_path.unlink() diff --git a/trinity/server.py b/trinity/server.py index 7da1823764..aaa44f2d2e 100644 --- a/trinity/server.py +++ b/trinity/server.py @@ -144,7 +144,7 @@ async def _close_tcp_listener(self) -> None: self._tcp_listener.close() await self._tcp_listener.wait_closed() - async def _run(self) -> None: + async def do_run(self) -> None: self.logger.info("Running server...") mapped_external_ip = await self.upnp_service.add_nat_portmap() if mapped_external_ip is None: @@ -185,7 +185,7 @@ async def _run(self) -> None: self.syncer = self._make_syncer() await self.syncer.run() - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: self.logger.info("Closing server...") await self._close_tcp_listener() diff --git a/trinity/sync/common/chain.py b/trinity/sync/common/chain.py index 7cd92906ef..37d8629284 100644 --- a/trinity/sync/common/chain.py +++ b/trinity/sync/common/chain.py @@ -109,7 +109,7 @@ def get_target_header_hash(self) -> Hash32: def tip_monitor_class(self) -> Type[BaseChainTipMonitor]: pass - async def _run(self) -> None: + async def do_run(self) -> None: self.run_daemon(self._tip_monitor) if self.peer_pool.event_bus is not None: self.run_daemon_task(self.handle_sync_status_requests()) @@ -204,7 +204,7 @@ def get_target_header_hash(self) -> Hash32: else: return self._target_header_hash - async def _run(self) -> None: + async def do_run(self) -> None: await self.events.cancelled.wait() async def next_header_batch(self) -> AsyncIterator[Tuple[BlockHeader, ...]]: diff --git a/trinity/sync/full/chain.py b/trinity/sync/full/chain.py index 3e6ba15405..ba8d305056 100644 --- a/trinity/sync/full/chain.py +++ b/trinity/sync/full/chain.py @@ -163,9 +163,9 @@ def __init__(self, buffer_size = MAX_BODIES_FETCH * REQUEST_BUFFER_MULTIPLIER self._block_body_tasks = TaskQueue(buffer_size, attrgetter('block_number')) - async def _run(self) -> None: + async def do_run(self) -> None: with self.subscribe(self.peer_pool): - await super()._run() + await super().do_run() async def _assign_body_download_to_peers(self) -> None: """ @@ -372,7 +372,7 @@ def __init__(self, dependency_extractor=attrgetter('parent_hash'), ) - async def _run(self) -> None: + async def do_run(self) -> None: head = await self.wait(self.db.coro_get_canonical_head()) self._block_persist_tracker.set_finished_dependency(head) self.run_daemon_task(self._launch_prerequisite_tasks()) @@ -380,7 +380,7 @@ async def _run(self) -> None: self.run_daemon_task(self._assign_body_download_to_peers()) self.run_daemon_task(self._persist_ready_blocks()) self.run_daemon_task(self._display_stats()) - await super()._run() + await super().do_run() def register_peer(self, peer: BasePeer) -> None: # when a new peer is added to the pool, add it to the idle peer lists @@ -740,13 +740,13 @@ def __init__(self, dependency_extractor=attrgetter('parent_hash'), ) - async def _run(self) -> None: + async def do_run(self) -> None: head = await self.wait(self.db.coro_get_canonical_head()) self._block_import_tracker.set_finished_dependency(head) self.run_daemon_task(self._launch_prerequisite_tasks()) self.run_daemon_task(self._assign_body_download_to_peers()) self.run_daemon_task(self._import_ready_blocks()) - await super()._run() + await super().do_run() def register_peer(self, peer: BasePeer) -> None: # when a new peer is added to the pool, add it to the idle peer list diff --git a/trinity/sync/full/service.py b/trinity/sync/full/service.py index e692925fc0..493cfd0a8a 100644 --- a/trinity/sync/full/service.py +++ b/trinity/sync/full/service.py @@ -35,7 +35,7 @@ def __init__(self, self.base_db = base_db self.peer_pool = peer_pool - async def _run(self) -> None: + async def do_run(self) -> None: head = await self.wait(self.chaindb.coro_get_canonical_head()) # We're still too slow at block processing, so if our local head is older than # FAST_SYNC_CUTOFF we first do a fast-sync run to catch up with the rest of the network. diff --git a/trinity/sync/full/state.py b/trinity/sync/full/state.py index 2e8181a6be..757ed3a329 100644 --- a/trinity/sync/full/state.py +++ b/trinity/sync/full/state.py @@ -137,7 +137,7 @@ async def _process_nodes(self, nodes: Iterable[Tuple[Hash32, bytes]]) -> None: # retry after a timeout. pass - async def _cleanup(self) -> None: + async def do_cleanup(self) -> None: self._nodes_cache_dir.cleanup() async def request_nodes(self, node_keys: Iterable[Hash32]) -> None: @@ -235,7 +235,7 @@ async def _periodically_retry_timedout_and_missing(self) -> None: next_timeout = self.request_tracker.get_next_timeout() await self.sleep(next_timeout - time.time()) - async def _run(self) -> None: + async def do_run(self) -> None: """Fetch all trie nodes starting from self.root_hash, and store them in self.db. Raises OperationCancelled if we're interrupted before that is completed. diff --git a/trinity/sync/light/chain.py b/trinity/sync/light/chain.py index 0e7cadb15d..147102b596 100644 --- a/trinity/sync/light/chain.py +++ b/trinity/sync/light/chain.py @@ -8,9 +8,9 @@ class LightChainSyncer(BaseHeaderChainSyncer): tip_monitor_class = LightChainTipMonitor - async def _run(self) -> None: + async def do_run(self) -> None: self.run_task(self._persist_headers()) - await super()._run() + await super().do_run() async def _persist_headers(self) -> None: while self.is_operational: diff --git a/trinity/sync/light/service.py b/trinity/sync/light/service.py index c91e420e1a..2207faef22 100644 --- a/trinity/sync/light/service.py +++ b/trinity/sync/light/service.py @@ -117,7 +117,7 @@ def __init__( # to be handled by the chain syncer), so our queue should never grow too much. msg_queue_maxsize = 500 - async def _run(self) -> None: + async def do_run(self) -> None: with self.subscribe(self.peer_pool): while self.is_operational: peer, cmd, msg = await self.wait(self.msg_queue.get())