mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Add type hints to routing folder
This commit is contained in:
@ -1,11 +1,23 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import (
|
||||
Any,
|
||||
Coroutine,
|
||||
Iterable,
|
||||
)
|
||||
|
||||
from libp2p.peer.id import (
|
||||
ID,
|
||||
)
|
||||
from libp2p.peer.peerinfo import (
|
||||
PeerInfo,
|
||||
)
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
|
||||
class IContentRouting(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def provide(self, cid, announce=True):
|
||||
def provide(self, cid: bytes, announce: bool=True) -> None:
|
||||
"""
|
||||
Provide adds the given cid to the content routing system. If announce is True,
|
||||
it also announces it, otherwise it is just kept in the local
|
||||
@ -13,7 +25,7 @@ class IContentRouting(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def find_provider_iter(self, cid, count):
|
||||
def find_provider_iter(self, cid: bytes, count: int) -> Iterable[PeerInfo]:
|
||||
"""
|
||||
Search for peers who are able to provide a given key
|
||||
returns an iterator of peer.PeerInfo
|
||||
@ -23,7 +35,7 @@ class IContentRouting(ABC):
|
||||
class IPeerRouting(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def find_peer(self, peer_id):
|
||||
def find_peer(self, peer_id: ID) -> Coroutine[Any, Any, PeerInfo]:
|
||||
"""
|
||||
Find specific Peer
|
||||
FindPeer searches for a peer with given peer_id, returns a peer.PeerInfo
|
||||
|
||||
Reference in New Issue
Block a user