implement new_node
This commit is contained in:
parent
716e061645
commit
64002acc64
|
@ -1,7 +1,8 @@
|
|||
from ..peer.peerstore import PeerStore
|
||||
from ..network.swarm import Swarm
|
||||
from ..host.basic_host import BasicHost
|
||||
from ..transport.upgrader import TransportUpgrader
|
||||
from peer.peerstore import PeerStore
|
||||
from network.swarm import Swarm
|
||||
from host.basic_host import BasicHost
|
||||
from transport.upgrader import TransportUpgrader
|
||||
from transport.tcp import TCP
|
||||
from Crypto.PublicKey import RSA
|
||||
|
||||
class Libp2p(object):
|
||||
|
@ -15,7 +16,6 @@ class Libp2p(object):
|
|||
if idOpt:
|
||||
self.idOpt = idOpt
|
||||
else:
|
||||
# TODO generate RSA public key pair
|
||||
new_key = RSA.generate(2048, e=65537)
|
||||
self.idOpt = new_key.publickey().exportKey("PEM")
|
||||
self.private_key = new_key.exportKey("PEM")
|
||||
|
@ -27,14 +27,14 @@ class Libp2p(object):
|
|||
|
||||
def new_node(self):
|
||||
|
||||
swarm = Swarm(self.idOpt, self.peerstore)
|
||||
host = BasicHost(swarm)
|
||||
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)
|
||||
|
||||
# TODO transport upgrade
|
||||
# TODO MuxedConnection currently contains all muxing logic
|
||||
# TODO routing unimplemented
|
||||
|
||||
# TODO listen on addrs
|
||||
|
||||
# TODO swarm add transports
|
||||
|
||||
# TODO: return host
|
||||
return host
|
||||
|
|
Loading…
Reference in New Issue
Block a user