mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
WIP CI Build Errors (#76)
* ignore TODO and kademlia * remove unnecessary pass * fixed swarm warnings * fixed peerdata_interface warnings * fixed peer warnings * fixed rest of linting errors * trying to fix last error * fixed dup errors
This commit is contained in:
@ -13,7 +13,6 @@ class IAddrBook(ABC):
|
||||
:param addr: multiaddress of the peer
|
||||
:param ttl: time-to-live for the address (after this time, address is no longer valid)
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_addrs(self, peer_id, addrs, ttl):
|
||||
@ -25,7 +24,6 @@ class IAddrBook(ABC):
|
||||
:param addr: multiaddresses of the peer
|
||||
:param ttl: time-to-live for the address (after this time, address is no longer valid
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def addrs(self, peer_id):
|
||||
@ -33,7 +31,6 @@ class IAddrBook(ABC):
|
||||
:param peer_id: peer to get addresses of
|
||||
:return: all known (and valid) addresses for the given peer
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def clear_addrs(self, peer_id):
|
||||
@ -41,12 +38,10 @@ class IAddrBook(ABC):
|
||||
Removes all previously stored addresses
|
||||
:param peer_id: peer to remove addresses of
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def peers_with_addrs(self):
|
||||
"""
|
||||
:return: all of the peer IDs stored with addresses
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -14,4 +14,4 @@ class ID:
|
||||
return "<peer.ID %s>" % pid
|
||||
return "<peer.ID %s*%s>" % (pid[:2], pid[len(pid)-6:])
|
||||
|
||||
__repr__ = __str__
|
||||
__repr__ = __str__
|
||||
|
||||
@ -31,9 +31,7 @@ class PeerData(IPeerData):
|
||||
def get_metadata(self, key):
|
||||
if key in self.metadata:
|
||||
return self.metadata[key]
|
||||
else:
|
||||
raise PeerDataError("key not found")
|
||||
raise PeerDataError("key not found")
|
||||
|
||||
class PeerDataError(KeyError):
|
||||
"""Raised when a key is not found in peer metadata"""
|
||||
pass
|
||||
|
||||
@ -7,42 +7,36 @@ class IPeerData(ABC):
|
||||
"""
|
||||
:return: all protocols associated with given peer
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_protocols(self, protocols):
|
||||
"""
|
||||
:param protocols: protocols to add
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def set_protocols(self, protocols):
|
||||
"""
|
||||
:param protocols: protocols to add
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_addrs(self, addrs):
|
||||
"""
|
||||
:param addrs: multiaddresses to add
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_addrs(self):
|
||||
"""
|
||||
:return: all multiaddresses
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def clear_addrs(self):
|
||||
"""
|
||||
Clear all addresses
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def put_metadata(self, key, val):
|
||||
@ -51,7 +45,6 @@ class IPeerData(ABC):
|
||||
:param val: val to associate with key
|
||||
:raise Exception: unsuccesful put
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_metadata(self, key):
|
||||
@ -60,4 +53,3 @@ class IPeerData(ABC):
|
||||
:return: val for key
|
||||
:raise Exception: key not found
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
class PeerInfo:
|
||||
# pylint: disable=too-few-public-methods
|
||||
def __init__(self, peer_id, peer_data):
|
||||
self.peer_id = peer_id
|
||||
self.addrs = peer_data.get_addrs()
|
||||
|
||||
@ -13,7 +13,6 @@ class IPeerMetadata(ABC):
|
||||
:return: value at key for given peer
|
||||
:raise Exception: peer ID not found
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def put(self, peer_id, key, val):
|
||||
@ -23,5 +22,4 @@ class IPeerMetadata(ABC):
|
||||
:param val: value to associated with key
|
||||
:raise Exception: unsuccessful put
|
||||
"""
|
||||
pass
|
||||
|
||||
@ -31,8 +31,7 @@ class PeerStore(IPeerStore):
|
||||
def get_protocols(self, peer_id):
|
||||
if peer_id in self.peer_map:
|
||||
return self.peer_map[peer_id].get_protocols()
|
||||
else:
|
||||
raise PeerStoreError("peer ID not found")
|
||||
raise PeerStoreError("peer ID not found")
|
||||
|
||||
def add_protocols(self, peer_id, protocols):
|
||||
peer = self.__create_or_get_peer(peer_id)
|
||||
@ -49,8 +48,7 @@ class PeerStore(IPeerStore):
|
||||
if peer_id in self.peer_map:
|
||||
val = self.peer_map[peer_id].get_metadata(key)
|
||||
return val
|
||||
else:
|
||||
raise PeerStoreError("peer ID not found")
|
||||
raise PeerStoreError("peer ID not found")
|
||||
|
||||
def put(self, peer_id, key, val):
|
||||
# <<?>>
|
||||
@ -69,8 +67,7 @@ class PeerStore(IPeerStore):
|
||||
def addrs(self, peer_id):
|
||||
if peer_id in self.peer_map:
|
||||
return self.peer_map[peer_id].get_addrs()
|
||||
else:
|
||||
raise PeerStoreError("peer ID not found")
|
||||
raise PeerStoreError("peer ID not found")
|
||||
|
||||
def clear_addrs(self, peer_id):
|
||||
# Only clear addresses if the peer is in peer map
|
||||
@ -88,4 +85,3 @@ class PeerStore(IPeerStore):
|
||||
|
||||
class PeerStoreError(KeyError):
|
||||
"""Raised when peer ID is not found in peer store"""
|
||||
pass
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from abc import abstractmethod
|
||||
from .addrbook_interface import IAddrBook
|
||||
from .peermetadata_interface import IPeerMetadata
|
||||
|
||||
@ -14,7 +14,6 @@ class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
:param peer_id: peer ID to get info for
|
||||
:return: peer info object
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_protocols(self, peer_id):
|
||||
@ -23,7 +22,6 @@ class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
:return: protocols (as strings)
|
||||
:raise Exception: peer ID not found exception
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def add_protocols(self, peer_id, protocols):
|
||||
@ -32,7 +30,6 @@ class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
:param protocols: protocols to add
|
||||
:raise Exception: peer ID not found
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def set_protocols(self, peer_id, protocols):
|
||||
@ -41,11 +38,9 @@ class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
:param protocols: protocols to set
|
||||
:raise Exception: peer ID not found
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def peers(self):
|
||||
"""
|
||||
:return: all of the peer IDs stored in peer store
|
||||
"""
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user