mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Add test for Swarm.close_peer
This commit is contained in:
@ -23,6 +23,10 @@ from .host_interface import IHost
|
||||
|
||||
|
||||
class BasicHost(IHost):
|
||||
"""
|
||||
BasicHost is a wrapper of a `INetwork` implementation. It performs protocol negotiation
|
||||
on a stream with multistream-select right after a stream is initialized.
|
||||
"""
|
||||
|
||||
_network: INetwork
|
||||
_router: KadmeliaPeerRouter
|
||||
@ -31,7 +35,6 @@ class BasicHost(IHost):
|
||||
multiselect: Multiselect
|
||||
multiselect_client: MultiselectClient
|
||||
|
||||
# default options constructor
|
||||
def __init__(self, network: INetwork, router: KadmeliaPeerRouter = None) -> None:
|
||||
self._network = network
|
||||
self._network.set_stream_handler(self._swarm_stream_handler)
|
||||
@ -69,6 +72,7 @@ class BasicHost(IHost):
|
||||
"""
|
||||
:return: all the multiaddr addresses this host is listening to
|
||||
"""
|
||||
# TODO: We don't need "/p2p/{peer_id}" postfix actually.
|
||||
p2p_part = multiaddr.Multiaddr("/p2p/{}".format(self.get_id().pretty()))
|
||||
|
||||
addrs: List[multiaddr.Multiaddr] = []
|
||||
@ -87,8 +91,6 @@ class BasicHost(IHost):
|
||||
"""
|
||||
self.multiselect.add_handler(protocol_id, stream_handler)
|
||||
|
||||
# `protocol_ids` can be a list of `protocol_id`
|
||||
# stream will decide which `protocol_id` to run on
|
||||
async def new_stream(
|
||||
self, peer_id: ID, protocol_ids: Sequence[TProtocol]
|
||||
) -> INetStream:
|
||||
|
||||
Reference in New Issue
Block a user