From 81a6da009a361a3bde342b27bddc702abee172a2 Mon Sep 17 00:00:00 2001 From: Emil Ivanichkov Date: Thu, 21 Mar 2024 18:52:21 +0200 Subject: [PATCH] feat(SNM): Install `waku exportHandshake` command --- src/status_node_manager.nim | 8 +++++++- src/status_node_manager/config.nim | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/status_node_manager.nim b/src/status_node_manager.nim index 0adc934..01b491f 100644 --- a/src/status_node_manager.nim +++ b/src/status_node_manager.nim @@ -81,6 +81,12 @@ proc doWakuPairing(config: StatusNodeManagerConfig, waitFor wakuPair(wakuClient, wakuPairRequestData) +proc doWakuHandshakeExport(config: StatusNodeManagerConfig, + wakuClient: var RestClientRef) = + let requestData = + WakuExportHandshakeRequestData(exportFile: $config.handshakeFile) + waitFor wakuExportHandshake(wakuClient, requestData) + proc doWakuCommand(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) = var wakuClient = RestClientRef.new(initTAddress(config.restAddress, config.restPort)) @@ -88,7 +94,7 @@ proc doWakuCommand(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) = of WakuCommand.pair: doWakuPairing(config, rng, wakuClient) of WakuCommand.exportHandshake: - discard + doWakuHandshakeExport(config, wakuClient) when isMainModule: setupLogLevel(LogLevel.NOTICE) diff --git a/src/status_node_manager/config.nim b/src/status_node_manager/config.nim index 3cae751..b1eb94b 100644 --- a/src/status_node_manager/config.nim +++ b/src/status_node_manager/config.nim @@ -12,6 +12,7 @@ export defaultSNMRestPort, defaultAdminListenAddress, parseCmdArg, completeCmdArg, `/` +const wakuHandshakeDataFilename* = "handshake_data.json" type SNMStartUpCmd* {.pure.} = enum @@ -104,7 +105,10 @@ type name: "pubsub-topic" .}: PubsubTopic of WakuCommand.exportHandshake: - discard + handshakeFile* {. + desc: "The file to export the waku handshake result to" + defaultValue: config.defaultDataDir() / "waku" / wakuHandshakeDataFilename + name: "handshake-file" .}: OutFile proc defaultDataDir*[Conf](config: Conf): string = let dataDir = when defined(windows):