diff --git a/waku/node/v2/start_network.nim b/waku/node/v2/start_network.nim index 44e8fcf2f..afac881dd 100644 --- a/waku/node/v2/start_network.nim +++ b/waku/node/v2/start_network.nim @@ -9,22 +9,23 @@ import # Fix ambiguous call error import strutils except fromHex +const + defaults ="--log-level:DEBUG --log-metrics --metrics-server --rpc" + wakuNodeBin = "build" / "wakunode" + type NodeInfo* = object cmd: string address: string + shift: int 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 = +proc initNodeCmd(shift: int, staticNodes: seq[string] = @[], label: string): NodeInfo = let key = SkPrivateKey.random() hkey = key.getBytes().toHex() @@ -38,6 +39,27 @@ proc initNodeCmd(): NodeInfo = hostAddress = MultiAddress.init(DefaultAddr) peerInfo.addrs.add(hostAddress) + let id = peerInfo.id - result.cmd = "./build/foo" + info "PeerInfo", id = id, addrs = peerInfo.addrs + let listenStr = $peerInfo.addrs[0] & "/p2p/" & id + result.cmd = wakuNodeBin & " " & defaults & " " + result.cmd &= "--nodekey:" & hkey & " " + result.cmd &= "--ports-shift:" & $shift & " " + if staticNodes.len > 0: + for staticNode in staticNodes: + result.cmd &= "--staticnode:" & staticNode & " " + result.shift = shift + result.label = label + result.address = listenStr + + info "Node command created.", cmd=result.cmd, address = result.address + +# TODO: Setup diff topology, star, mesh, etc +let masterNode = initNodeCmd(0, @[], "master node") +let otherNode = initNodeCmd(0, @[masterNode.address], "other node") + +echo masterNode +echo "---" +echo otherNode