mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-12 08:00:54 +00:00
Pull request feedback
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
import json
|
||||
from typing import Any, List, Sequence
|
||||
|
||||
import multiaddr
|
||||
@ -14,11 +13,6 @@ class PeerInfo:
|
||||
self.peer_id = peer_id
|
||||
self.addrs = list(addrs)
|
||||
|
||||
def to_string(self) -> str:
|
||||
return json.dumps(
|
||||
[self.peer_id.to_string(), list(map(lambda a: str(a), self.addrs))]
|
||||
)
|
||||
|
||||
def __eq__(self, other: Any) -> bool:
|
||||
return (
|
||||
isinstance(other, PeerInfo)
|
||||
@ -26,14 +20,6 @@ class PeerInfo:
|
||||
and self.addrs == other.addrs
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def info_from_string(cls, info: str) -> "PeerInfo":
|
||||
peer_id, raw_addrs = json.loads(info)
|
||||
return PeerInfo(
|
||||
ID.from_base58(peer_id),
|
||||
list(map(lambda a: multiaddr.Multiaddr(a), raw_addrs)),
|
||||
)
|
||||
|
||||
|
||||
def info_from_p2p_addr(addr: multiaddr.Multiaddr) -> PeerInfo:
|
||||
if not addr:
|
||||
|
||||
Reference in New Issue
Block a user