From b89710a40b357f981c77f2cd3eefc684e9108174 Mon Sep 17 00:00:00 2001 From: zixuanzh Date: Fri, 26 Oct 2018 22:09:39 +0200 Subject: [PATCH] transport interface --- network/transport_interface.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/network/transport_interface.py b/network/transport_interface.py index e69de29b..324ea43b 100644 --- a/network/transport_interface.py +++ b/network/transport_interface.py @@ -0,0 +1,24 @@ +from abc import ABC, abstractmethod + +class ITransport(ABC): + + @abstractmethod + def dial(self, multiaddr, options=None): + """ + dial a transport to peer listening on multiaddr + :param multiaddr: multiaddr of peer + :param options: optional object + :return: list of multiaddrs + """ + pass + + @abstractmethod + def create_listener(self, handler_function, options=None): + """ + create listener on transport + :param options: optional object with properties the listener must have + :param handler_function: a function called when a new conntion is received + that takes a connection as argument which implements interface-connection + :return: a listener object that implements listener_interface.py + """ + pass