minor fix

This commit is contained in:
Robert Zajac 2018-11-11 20:46:32 -05:00
commit e2b7ad8926
2 changed files with 9 additions and 9 deletions

View File

@ -2,6 +2,7 @@ from peer.peerstore import PeerStore
from network.swarm import Swarm from network.swarm import Swarm
from host.basic_host import BasicHost from host.basic_host import BasicHost
from transport.upgrader import TransportUpgrader from transport.upgrader import TransportUpgrader
from transport.tcp.tcp import TCP
from Crypto.PublicKey import RSA from Crypto.PublicKey import RSA
class Libp2p(object): class Libp2p(object):
@ -26,14 +27,14 @@ class Libp2p(object):
def new_node(self): def new_node(self):
swarm = Swarm(self.idOpt, self.peerstore) upgrader = TransportUpgrader(self.secOpt, self.transportOpt)
swarm = Swarm(self.idOpt, self.peerstore, upgrader)
tcp = TCP()
swarm.add_transport(tcp)
swarm.listen(self.transportOpts)
host = BasicHost(swarm) host = BasicHost(swarm)
upgrader = TransportUpgrader(self.secOpt, self.muxerOpt)
# TODO transport upgrade # TODO MuxedConnection currently contains all muxing logic
# TODO routing unimplemented
# TODO listen on addrs return host
# TODO swarm add transports
# TODO: return host

View File

@ -88,7 +88,6 @@ class Swarm(INetwork):
raw_conn = RawConnection(multiaddr_dict.host, multiaddr_dict.port, reader, writer) raw_conn = RawConnection(multiaddr_dict.host, multiaddr_dict.port, reader, writer)
muxed_conn = self.upgrader.upgrade_connection(raw_conn, False) muxed_conn = self.upgrader.upgrade_connection(raw_conn, False)
# TODO: make generic protocols work
muxed_stream, stream_id, protocol_id = muxed_conn.accept_stream() muxed_stream, stream_id, protocol_id = muxed_conn.accept_stream()
net_stream = NetStream(muxed_stream) net_stream = NetStream(muxed_stream)
net_stream.set_protocol(protocol_id) net_stream.set_protocol(protocol_id)