Pull request feedback

This commit is contained in:
Aratz M. Lasa
2019-10-15 20:32:25 +02:00
parent fa1637850e
commit ac9feef26c
5 changed files with 31 additions and 24 deletions

View File

@ -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: