mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
added getter for connected peers
This commit is contained in:
committed by
Paul Robinson
parent
a10b8fdb91
commit
847dfa6577
@ -145,6 +145,9 @@ class BasicHost(IHost):
|
||||
addrs.append(addr.encapsulate(p2p_part))
|
||||
return addrs
|
||||
|
||||
def get_connected_peers(self) -> List[ID]:
|
||||
return list(self.get_network().connections.keys())
|
||||
|
||||
@asynccontextmanager
|
||||
async def run(
|
||||
self, listen_addrs: Sequence[multiaddr.Multiaddr]
|
||||
|
||||
@ -71,6 +71,12 @@ class IHost(ABC):
|
||||
:return: all the multiaddr addresses this host is listening to
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_connected_peers(self) -> List[ID]:
|
||||
"""
|
||||
:return: all the ids of peers this host is currently connected to
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def run(
|
||||
self, listen_addrs: Sequence[multiaddr.Multiaddr]
|
||||
|
||||
Reference in New Issue
Block a user