From 4889a0a790c61e0925d78169024756b75dfb190f Mon Sep 17 00:00:00 2001 From: Christophe de Carvalho Pereira Martins Date: Tue, 15 Jan 2019 18:43:54 +0100 Subject: [PATCH] First POC of peer routing using kademlia lib --- libp2p/routing/__init__.py | 0 libp2p/routing/interfaces.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 libp2p/routing/__init__.py create mode 100644 libp2p/routing/interfaces.py diff --git a/libp2p/routing/__init__.py b/libp2p/routing/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/libp2p/routing/interfaces.py b/libp2p/routing/interfaces.py new file mode 100644 index 00000000..1f29d48c --- /dev/null +++ b/libp2p/routing/interfaces.py @@ -0,0 +1,31 @@ +from abc import ABC, abstractmethod +# pylint: disable=too-few-public-methods + + +class IContentRouting(ABC): + + @abstractmethod + def provide(self, cid, announce=True): + """ + 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 + accounting of which objects are being provided. + """ + + @abstractmethod + def find_provider_iter(self, cid, count): + """ + Search for peers who are able to provide a given key + returns an iterator of peer.PeerInfo + """ + + +class IPeerRouting(ABC): + + @abstractmethod + def find_peer(self, peer_id): + """ + Find specific Peer + FindPeer searches for a peer with given peer_id, returns a peer.PeerInfo + with relevant addresses. + """