From 693a8cf99ae1365b2da45294c2ce4eb30597d21a Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Mon, 28 Oct 2019 18:48:00 +0900 Subject: [PATCH] Default protocols are constructed using a reference to the host --- libp2p/host/basic_host.py | 2 +- libp2p/host/defaults.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libp2p/host/basic_host.py b/libp2p/host/basic_host.py index 73218d3..013c62b 100644 --- a/libp2p/host/basic_host.py +++ b/libp2p/host/basic_host.py @@ -55,7 +55,7 @@ class BasicHost(IHost): self._network.set_stream_handler(self._swarm_stream_handler) self.peerstore = self._network.peerstore # Protocol muxing - default_protocols = default_protocols or get_default_protocols() + default_protocols = default_protocols or get_default_protocols(self) self.multiselect = Multiselect(default_protocols) self.multiselect_client = MultiselectClient() diff --git a/libp2p/host/defaults.py b/libp2p/host/defaults.py index ab5952f..a311132 100644 --- a/libp2p/host/defaults.py +++ b/libp2p/host/defaults.py @@ -1,11 +1,11 @@ from collections import OrderedDict from typing import TYPE_CHECKING +from libp2p.host.host_interface import IHost + if TYPE_CHECKING: from libp2p.typing import TProtocol, StreamHandlerFn -DEFAULT_HOST_PROTOCOLS: "OrderedDict[TProtocol, StreamHandlerFn]" = OrderedDict() - -def get_default_protocols() -> "OrderedDict[TProtocol, StreamHandlerFn]": - return DEFAULT_HOST_PROTOCOLS.copy() +def get_default_protocols(host: IHost) -> "OrderedDict[TProtocol, StreamHandlerFn]": + return OrderedDict()