diff --git a/host/basic_host.py b/host/basic_host.py index 7f5fdef..b0c5a7d 100644 --- a/host/basic_host.py +++ b/host/basic_host.py @@ -1,4 +1,9 @@ from host_interface import Host +# Upon host creation, host takes in options, +# including the list of addresses on which to listen. +# Host then parses these options and delegates to its Network instance, +# telling it to listen on the given listen addresses. + class BasicHost(Host): pass \ No newline at end of file diff --git a/host/host_interface.py b/host/host_interface.py index 367128c..ac53c23 100644 --- a/host/host_interface.py +++ b/host/host_interface.py @@ -33,17 +33,19 @@ class Host(ABC): """ set stream handler for host :param protocol_id: protocol id used on stream - :param stream_handler: a stream handler instance + :param stream_handler: a stream handler function :return: true if successful """ pass + # protocol_id can be a list of protocol_ids + # stream will decide which protocol_id to run on @abstractmethod - def new_stream(self, context, peer_id, protocol_ids): + def new_stream(self, context, peer_id, protocol_id): """ :param context: a context instance :param peer_id: peer_id that host is connecting - :param proto_ids: list of protocol ids that stream runs on + :param proto_id: protocol id that stream runs on :return: true if successful """ pass \ No newline at end of file diff --git a/network/stream_interface.py b/network/stream_interface.py index dc0a519..3d92d8e 100644 --- a/network/stream_interface.py +++ b/network/stream_interface.py @@ -36,3 +36,12 @@ class Stream(ABC): :return: number of bytes written """ pass + + @abstractmethod + def close(): + """ + close stream + :return: true if successful + """ + pass +