diff --git a/network/stream.py b/network/stream.py index 024740c..04b8bda 100644 --- a/network/stream.py +++ b/network/stream.py @@ -3,13 +3,11 @@ import asyncio class Stream(IStream): - def __init__(self, peer_id): + def __init__(self, peer_id, maddr): self.peer_id = peer_id - peer_store = context.peer_store - peer_addr = peer_store.get(peer_id) - ip = peer_addr.get_protocol("ip4") - port = peer_addr.get_protocol("tcp") + ip = maddr.get_protocol_value("ip4") + port = maddr.get_protocol_value("tcp") # look up peer_id -> multiaddr in peer store # parse multiaddr and set_protocol based on it diff --git a/network/stream_interface.py b/network/stream_interface.py index 4649e73..b6ab342 100644 --- a/network/stream_interface.py +++ b/network/stream_interface.py @@ -2,8 +2,9 @@ from abc import ABC, abstractmethod class IStream(ABC): - def __init__(self, peer_id): + def __init__(self, peer_id, maddr): self.peer_id = peer_id + self.maddr = maddr @abstractmethod def protocol(self):