Describe listen stub

This commit is contained in:
Stuckinaboot 2018-11-11 17:10:37 -05:00
parent 4851137ece
commit f6f2f6725d

View File

@ -7,8 +7,9 @@ class Swarm(INetwork):
def __init__(self, my_peer_id, peerstore, upgrader): def __init__(self, my_peer_id, peerstore, upgrader):
self.my_peer_id = my_peer_id self.my_peer_id = my_peer_id
self.peerstore = peerstore self.peerstore = peerstore
self.connections = {}
self.upgrader = upgrader self.upgrader = upgrader
self.connections = dict()
self.listeners = dict()
def set_stream_handler(self, stream_handler): def set_stream_handler(self, stream_handler):
""" """
@ -62,7 +63,24 @@ class Swarm(INetwork):
:param *args: one or many multiaddrs to start listening on :param *args: one or many multiaddrs to start listening on
:return: true if at least one success :return: true if at least one success
""" """
pass
# Create a closure C that takes in a multiaddr and
# returns a function object O that takes in a reader and writer.
# This function O looks up the stream handler
# for the given protocol, creates the net_stream
# for the listener and calls the stream handler function
# passing in the net_stream
# For each multiaddr in args
# Check if a listener for multiaddr exists already
# If listener already exists, continue
# Otherwise, do the following:
# Pass multiaddr into C and get back function H
# listener = transport.create_listener(H)
# Call listener listen with the multiaddr
# Map multiaddr to listener
return True
def add_transport(self, transport): def add_transport(self, transport):
# TODO: Support more than one transport # TODO: Support more than one transport