From e0a94b6092cb31c30677cf3ed2f2fefb8c174d6a Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Mon, 28 Oct 2019 18:47:10 +0900 Subject: [PATCH] identify handler reads data on request from the host --- libp2p/identity/identify/protocol.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libp2p/identity/identify/protocol.py b/libp2p/identity/identify/protocol.py index 75a7ba3..0fc65ba 100644 --- a/libp2p/identity/identify/protocol.py +++ b/libp2p/identity/identify/protocol.py @@ -4,6 +4,7 @@ from typing import Sequence from multiaddr import Multiaddr from libp2p.crypto.keys import PublicKey +from libp2p.host.host_interface import IHost from libp2p.network.stream.net_stream_interface import INetStream from libp2p.typing import StreamHandlerFn, TProtocol @@ -20,13 +21,15 @@ def _multiaddr_to_bytes(maddr: Multiaddr) -> bytes: return maddr.to_bytes() -def identify_handler_for( - public_key: PublicKey, laddrs: Sequence[Multiaddr], protocols: Sequence[TProtocol] -) -> StreamHandlerFn: +def identify_handler_for(host: IHost) -> StreamHandlerFn: async def handle_identify(stream: INetStream) -> None: peer_id = stream.muxed_conn.peer_id logger.debug("received a request for %s from %s", ID, peer_id) + public_key = host.get_public_key() + laddrs = host.get_addrs() + protocols = host.get_mux().get_protocols() + protobuf = Identify( protocol_version=PROTOCOL_VERSION, agent_version=AGENT_VERSION,