diff --git a/waku.nimble b/waku.nimble index 0938e51e5..bef2e52aa 100644 --- a/waku.nimble +++ b/waku.nimble @@ -60,5 +60,4 @@ task wakunode2, "Build Experimental Waku cli": task wakusim2, "Build Experimental Waku simulation tools": buildBinary "quicksim", "waku/node/v2/", "-d:chronicles_log_level=DEBUG" - # TODO - #buildBinary "start_network", "waku/node/v2/", "-d:chronicles_log_level=DEBUG" + buildBinary "start_network", "waku/node/v2/", "-d:chronicles_log_level=DEBUG" diff --git a/waku/node/v2/quicksim.nim b/waku/node/v2/quicksim.nim index 54c5f8e07..67dccce01 100644 --- a/waku/node/v2/quicksim.nim +++ b/waku/node/v2/quicksim.nim @@ -14,6 +14,8 @@ template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] const sigWakuPath = &"{sourceDir}{DirSep}rpc{DirSep}wakucallsigs.nim" createRpcSigs(RpcHttpClient, sigWakuPath) +# TODO: This should have start_network + # More minimal than v1 quicksim, just RPC client for now let node1 = newRpcHttpClient() @@ -23,15 +25,6 @@ let node1 = newRpcHttpClient() # Using with static nodes, hardcoded "works": # /ip4/127.0.0.1/tcp/55505/ipfs/16Uiu2HAkufRTzUnYCMggjPaAMbC3ss1bkrjewPcjwSeqK9WgUKYu -# static node parsing ignored for now -#./build/wakunode2 --staticnode:/ip4/hallibaba/foo --ports-shift:1 - -# node 1: -# WRN 2020-05-01 12:20:13+08:00 no handlers for tid=24636 protocol=/vac/waku/2.0.0-alpha0 topic=Multistream - - - - # Need to figure out rw stuff as well, perhaps we can start a few nodes and see if we get some pingpong # Unclear how to mount waku on top of gossipsub tho diff --git a/waku/node/v2/start_network.nim b/waku/node/v2/start_network.nim new file mode 100644 index 000000000..f20fe40d0 --- /dev/null +++ b/waku/node/v2/start_network.nim @@ -0,0 +1,36 @@ +import + strformat, os, osproc, net, confutils, strformat, chronicles, json, strutils, + libp2p/multiaddress, + libp2p/crypto/crypto, + libp2p/protocols/protocol, + libp2p/peerinfo + +type + NodeInfo* = object + cmd: string + address: string + label: string + +# TODO: initNodeCmd and get multiaddress here +# TODO: Then, setup a star network + +# TODO: Create Node command, something like this: +# "build/wakunode --log-level:DEBUG --log-metrics --metrics-server --rpc --waku-topic-interest:false --nodekey:e685079b7fa34dd35d3ffb2e40ab970360e94aa7dcc1262d36a8e2320a2c08ce --ports-shift:2 --discovery:off " +# What's equivalent of nodekey for libp2p? It is keypair.seckey in v1 +# desc: "P2P node private key as hex.", +# Should be straightforward +# Ok cool so it is config.nim parseCmdArg, then use fromHex +proc initNodeCmd(): NodeInfo = + let + privKey = PrivateKey.random(Secp256k1) + keys = KeyPair(seckey: privKey, pubkey: privKey.getKey()) + peerInfo = PeerInfo.init(privKey) + # XXX + DefaultAddr = "/ip4/127.0.0.1/tcp/55505" + hostAddress = MultiAddress.init(DefaultAddr) + + peerInfo.addrs.add(hostAddress) + + result.cmd = "./build/foo" + +# TODO: main and toHex fromHex private keys, then in config as nodekey