feat(SNM config): Introduce `waku` command

This commit is contained in:
Emil Ivanichkov 2024-03-19 16:06:44 +02:00 committed by Emil Ivanichkov
parent 89e8cdde91
commit 7efde4011a
2 changed files with 35 additions and 17 deletions

View File

@ -70,10 +70,9 @@ proc doRunStatusNodeManager*(config: StatusNodeManagerConfig,
let snm = waitFor SNM.init(rng, config)
waitFor snm.run()
proc doWakuPairing(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) =
var wakuClient = RestClientRef.new(initTAddress(config.restAddress,
config.restPort))
proc doWakuPairing(config: StatusNodeManagerConfig,
rng: ref HmacDrbgContext,
wakuClient: var RestClientRef) =
let wakuPairRequestData = WakuPairRequestData(
qr: config.qr,
qrMessageNameTag: config.qrMessageNameTag,
@ -82,6 +81,15 @@ proc doWakuPairing(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) =
waitFor wakuPair(wakuClient, wakuPairRequestData)
proc doWakuCommand(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) =
var wakuClient = RestClientRef.new(initTAddress(config.restAddress,
config.restPort))
case config.wakuCmd
of WakuCommand.pair:
doWakuPairing(config, rng, wakuClient)
of WakuCommand.exportHandshake:
discard
when isMainModule:
setupLogLevel(LogLevel.NOTICE)
@ -91,5 +99,5 @@ when isMainModule:
case conf.cmd
of SNMStartUpCmd.noCommand: doRunStatusNodeManager(conf, rng)
of SNMStartUpCmd.pair: doWakuPairing(conf, rng)
of SNMStartUpCmd.waku: doWakuCommand(conf, rng)

View File

@ -13,7 +13,11 @@ export
type
SNMStartUpCmd* {.pure.} = enum
noCommand,
waku,
WakuCommand* {.pure.} = enum
pair,
exportHandshake
type
StatusNodeManagerConfig* = object
@ -71,17 +75,23 @@ type
defaultValue: 2
name: "required-connected-peers" .}: int
of SNMStartUpCmd.pair:
qr* {.
desc: "A string representation of the QR code produced by the GUI"
name: "qr" .}: string
of SNMStartUpCmd.waku:
case wakuCmd* {.command.}: WakuCommand
qrMessageNameTag* {.
desc: "A string representation of the initial message nametag produced" &
"by the GUI. It is used for the initial hadnshake message"
name: "qr-message-nametag" .}: string
of WakuCommand.pair:
qr* {.
desc: "A string representation of the QR code produced by the GUI"
name: "qr" .}: string
pubSubTopic* {.
desc: "The topic to subscribe to"
defaultValue: "/waku/2/default-waku/proto"
name: "pubsub-topic" .}: PubsubTopic
qrMessageNameTag* {.
desc: "A string representation of the initial message nametag produced" &
"by the GUI. It is used for the initial hadnshake message"
name: "qr-message-nametag" .}: string
pubSubTopic* {.
desc: "The topic to subscribe to"
defaultValue: "/waku/2/default-waku/proto"
name: "pubsub-topic" .}: PubsubTopic
of WakuCommand.exportHandshake:
discard