mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-10 07:00:54 +00:00
Merge pull request #331 from dmuhs/fix/docs-format
Add automatic docstring formatting
This commit is contained in:
@ -14,6 +14,7 @@ class IAddrBook(ABC):
|
||||
def add_addr(self, peer_id: ID, addr: Multiaddr, ttl: int) -> None:
|
||||
"""
|
||||
Calls add_addrs(peer_id, [addr], ttl)
|
||||
|
||||
:param peer_id: the peer to add address for
|
||||
:param addr: multiaddress of the peer
|
||||
:param ttl: time-to-live for the address (after this time, address is no longer valid)
|
||||
@ -22,9 +23,11 @@ class IAddrBook(ABC):
|
||||
@abstractmethod
|
||||
def add_addrs(self, peer_id: ID, addrs: Sequence[Multiaddr], ttl: int) -> None:
|
||||
"""
|
||||
Adds addresses for a given peer all with the same time-to-live. If one of the
|
||||
addresses already exists for the peer and has a longer TTL, no operation should take place.
|
||||
If one of the addresses exists with a shorter TTL, extend the TTL to equal param ttl.
|
||||
Adds addresses for a given peer all with the same time-to-live. If one
|
||||
of the addresses already exists for the peer and has a longer TTL, no
|
||||
operation should take place. If one of the addresses exists with a
|
||||
shorter TTL, extend the TTL to equal param ttl.
|
||||
|
||||
:param peer_id: the peer to add address for
|
||||
:param addr: multiaddresses of the peer
|
||||
:param ttl: time-to-live for the address (after this time, address is no longer valid
|
||||
@ -40,7 +43,8 @@ class IAddrBook(ABC):
|
||||
@abstractmethod
|
||||
def clear_addrs(self, peer_id: ID) -> None:
|
||||
"""
|
||||
Removes all previously stored addresses
|
||||
Removes all previously stored addresses.
|
||||
|
||||
:param peer_id: peer to remove addresses of
|
||||
"""
|
||||
|
||||
|
||||
@ -44,4 +44,4 @@ class PeerData(IPeerData):
|
||||
|
||||
|
||||
class PeerDataError(KeyError):
|
||||
"""Raised when a key is not found in peer metadata"""
|
||||
"""Raised when a key is not found in peer metadata."""
|
||||
|
||||
@ -39,9 +39,7 @@ class IPeerData(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def clear_addrs(self) -> None:
|
||||
"""
|
||||
Clear all addresses
|
||||
"""
|
||||
"""Clear all addresses."""
|
||||
|
||||
@abstractmethod
|
||||
def put_metadata(self, key: str, val: Any) -> None:
|
||||
|
||||
@ -18,9 +18,9 @@ class PeerStore(IPeerStore):
|
||||
|
||||
def __create_or_get_peer(self, peer_id: ID) -> PeerData:
|
||||
"""
|
||||
Returns the peer data for peer_id or creates a new
|
||||
peer data (and stores it in peer_map) if peer
|
||||
data for peer_id does not yet exist
|
||||
Returns the peer data for peer_id or creates a new peer data (and
|
||||
stores it in peer_map) if peer data for peer_id does not yet exist.
|
||||
|
||||
:param peer_id: peer ID
|
||||
:return: peer data
|
||||
"""
|
||||
@ -96,4 +96,4 @@ class PeerStore(IPeerStore):
|
||||
|
||||
|
||||
class PeerStoreError(KeyError):
|
||||
"""Raised when peer ID is not found in peer store"""
|
||||
"""Raised when peer ID is not found in peer store."""
|
||||
|
||||
Reference in New Issue
Block a user