mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Add type hints to peer folder
This commit is contained in:
@ -1,24 +1,31 @@
|
||||
from abc import abstractmethod
|
||||
from typing import (
|
||||
List,
|
||||
Sequence,
|
||||
)
|
||||
|
||||
|
||||
from .id import ID
|
||||
from .peerinfo import PeerInfo
|
||||
from .addrbook_interface import IAddrBook
|
||||
from .peermetadata_interface import IPeerMetadata
|
||||
|
||||
|
||||
class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
IPeerMetadata.__init__(self)
|
||||
IAddrBook.__init__(self)
|
||||
|
||||
@abstractmethod
|
||||
def peer_info(self, peer_id):
|
||||
def peer_info(self, peer_id: ID) -> PeerInfo:
|
||||
"""
|
||||
:param peer_id: peer ID to get info for
|
||||
:return: peer info object
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_protocols(self, peer_id):
|
||||
def get_protocols(self, peer_id: ID) -> List[str]:
|
||||
"""
|
||||
:param peer_id: peer ID to get protocols for
|
||||
:return: protocols (as strings)
|
||||
@ -26,7 +33,7 @@ class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def add_protocols(self, peer_id, protocols):
|
||||
def add_protocols(self, peer_id: ID, protocols: Sequence[str]) -> None:
|
||||
"""
|
||||
:param peer_id: peer ID to add protocols for
|
||||
:param protocols: protocols to add
|
||||
@ -34,7 +41,7 @@ class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def set_protocols(self, peer_id, protocols):
|
||||
def set_protocols(self, peer_id: ID, protocols: Sequence[str]) -> None:
|
||||
"""
|
||||
:param peer_id: peer ID to set protocols for
|
||||
:param protocols: protocols to set
|
||||
@ -42,7 +49,7 @@ class IPeerStore(IAddrBook, IPeerMetadata):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def peers(self):
|
||||
def peer_ids(self) -> List[ID]:
|
||||
"""
|
||||
:return: all of the peer IDs stored in peer store
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user