From e157c3f654cb50b6890c05f6cbfe402694fbe1b6 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Tue, 24 Sep 2019 19:15:32 -0700 Subject: [PATCH] typing fixes --- libp2p/host/ping.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libp2p/host/ping.py b/libp2p/host/ping.py index 9f43d16..110a083 100644 --- a/libp2p/host/ping.py +++ b/libp2p/host/ping.py @@ -1,8 +1,9 @@ +import asyncio import logging from libp2p.network.stream.exceptions import StreamEOF, StreamReset from libp2p.network.stream.net_stream_interface import INetStream -from libp2p.peer.id import ID +from libp2p.peer.id import ID as PeerID ID = "/ipfs/ping/1.0.0" PING_LENGTH = 32 @@ -11,7 +12,7 @@ RESP_TIMEOUT = 60 logger = logging.getLogger("libp2p.host.ping") -async def _handle_ping(stream: INetStream, peer_id: ID) -> None: +async def _handle_ping(stream: INetStream, peer_id: PeerID) -> None: try: payload = await asyncio.wait_for(stream.read(PING_LENGTH), RESP_TIMEOUT) except asyncio.TimeoutError as error: @@ -31,7 +32,7 @@ async def _handle_ping(stream: INetStream, peer_id: ID) -> None: await stream.write(payload) -async def handle_ping(self, stream: INetStream) -> None: +async def handle_ping(stream: INetStream) -> None: """ ``handle_ping`` responds to incoming ping requests until one side errors or closes the ``stream``.