From fa6fdc5d5381e18ce6a0ce442bf0fe8dc8fef0d6 Mon Sep 17 00:00:00 2001 From: Emil Ivanichkov Date: Thu, 15 Feb 2024 15:09:50 +0200 Subject: [PATCH] feat(cli/pair): Implement `pair` CLI command --- src/status_node_manager.nim | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/status_node_manager.nim b/src/status_node_manager.nim index 32a07d8..4a86368 100644 --- a/src/status_node_manager.nim +++ b/src/status_node_manager.nim @@ -1,13 +1,37 @@ -# This is just an example to get you started. A typical hybrid package -# uses this file as the main entry point of the application. - import + std/[strutils, typetraits], confutils, - status_node_manager/[ + chronos, + libp2p/crypto/crypto, + eth/[p2p/discoveryv5/enr], + chronicles/[log_output, topics_registry], + waku/[waku_core] + +import status_node_manager/[ config, helpers/submodule # TODO: remove me ] +import ../libs/waku_utils/waku_pair + +proc setupLogLevel*(level: LogLevel) = + topics_registry.setLogLevel(level) + +proc doWakuPairing(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) = + let wakuPairResult = waitFor wakuPair(rng, config.qr, config.qrMessageNameTag, + config.wakuPort, config.discv5Port, + config.requiredConnectedPeers, + config.pubSubTopic) + echo wakuPairResult.wakuHandshakeResult + when isMainModule: - let conf = load Config - echo(getWelcomeMessage()) # TODO: remove me + setupLogLevel(LogLevel.NOTICE) + + let rng = crypto.newRng() + + let conf = load StatusNodeManagerConfig + + case conf.cmd + of SNMStartUpCmd.noCommand: echo(getWelcomeMessage()) # TODO: remove me + of SNMStartUpCmd.pair: doWakuPairing(conf, rng) +