From 149c7133a0dbe710663972cc8c33f20dfed1eb26 Mon Sep 17 00:00:00 2001 From: Oskar Thoren Date: Mon, 27 Apr 2020 12:43:41 +0800 Subject: [PATCH] Log peerinfo and listening on --- hello_gossipsub/waku/wakunode.nim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hello_gossipsub/waku/wakunode.nim b/hello_gossipsub/waku/wakunode.nim index a0db006..8e9d5b7 100644 --- a/hello_gossipsub/waku/wakunode.nim +++ b/hello_gossipsub/waku/wakunode.nim @@ -7,7 +7,8 @@ import ../vendor/nimbus/nimbus/rpc/[waku, wakusim, key_storage], ../vendor/nim-libp2p/libp2p/standard_setup, ../vendor/nim-libp2p/libp2p/crypto/crypto, - ../vendor/nim-libp2p/libp2p/protocols/protocol + ../vendor/nim-libp2p/libp2p/protocols/protocol, + ../vendor/nim-libp2p/libp2p/peerinfo # TODO: Better aliasing of vendor dirs @@ -208,9 +209,12 @@ proc runWithLibP2P(config: WakuNodeConf) = #keys = crypto.KeyPair(nodekey) privKey = PrivateKey.random(Secp256k1) keys = KeyPair(seckey: privKey, pubkey: privKey.getKey()) + peerInfo = PeerInfo.init(privKey) info "Initializing networking (host address and announced same)", address + peerInfo.addrs.add(Multiaddress.init(DefaultAddr)) + # TODO: Here setup a libp2p node # Essentially something like this in nbc/eth2_network: # proc createEth2Node*(conf: BeaconNodeConf): Future[Eth2Node] @@ -229,6 +233,16 @@ proc runWithLibP2P(config: WakuNodeConf) = let wakuProto = newWakuProto(switch) switch.mount(wakuProto) + # TODO: Make context async + #let fut = await switch.start() + discard switch.start() + wakuProto.started = true + + let id = peerInfo.peerId.pretty + info "PeerInfo", id = id, addrs = peerInfo.addrs + let listenStr = $peerInfo.addrs[0] & "/ipfs/" & id + info "Listening on", full = listenStr + # Set-up node # var node = newEthereumNode(config.nodekey, address, 1, nil, clientId,