From 17c778de156426b5cc633fdb57a5e542fda3591a Mon Sep 17 00:00:00 2001 From: Alex Haynes Date: Sun, 24 Feb 2019 18:37:56 -0500 Subject: [PATCH] Peer Discovery Interface (#123) * added file * basic interface modeled on go repo * fixed linting * updated based on comments --- libp2p/discovery/advertiser_interface.py | 16 ++++++++++++++++ libp2p/discovery/discoverer_interface.py | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 libp2p/discovery/advertiser_interface.py create mode 100644 libp2p/discovery/discoverer_interface.py diff --git a/libp2p/discovery/advertiser_interface.py b/libp2p/discovery/advertiser_interface.py new file mode 100644 index 0000000..6c7297d --- /dev/null +++ b/libp2p/discovery/advertiser_interface.py @@ -0,0 +1,16 @@ +from abc import ABC, abstractmethod +# pylint: disable=too-few-public-methods + +class IAdvertiser(ABC): + + def __init__(self): + pass + + @abstractmethod + def advertise(self, service): + """ + Advertise providing a specific service to the network + :param service: service that you provide + :raise Exception: network error + """ + \ No newline at end of file diff --git a/libp2p/discovery/discoverer_interface.py b/libp2p/discovery/discoverer_interface.py new file mode 100644 index 0000000..4924d29 --- /dev/null +++ b/libp2p/discovery/discoverer_interface.py @@ -0,0 +1,17 @@ +from abc import ABC, abstractmethod +# pylint: disable=too-few-public-methods + + +class IDiscoverer(ABC): + + def __init__(self): + pass + + @abstractmethod + def find_peers(self, service): + """ + Find peers on the networking providing a particular service + :param service: service that peers must provide + :return: PeerInfo generator that yields PeerInfo objects for discovered peers + :raise Exception: network error + """