chore: remove dupe handling of the private key

This commit is contained in:
fryorcraken 2024-07-12 15:25:49 +10:00 committed by fryorcraken
parent 4efa7a1879
commit 222be9eb13
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 13 additions and 4 deletions

View File

@ -44,7 +44,6 @@ type Waku* = object
version: string
conf: WakuNodeConf
rng: ref HmacDrbgContext
key: crypto.PrivateKey
wakuDiscv5*: WakuDiscoveryV5
dynamicBootstrapNodes: seq[RemotePeerInfo]
@ -54,6 +53,9 @@ type Waku* = object
restServer*: WakuRestServerRef
metricsServer*: MetricsHttpServerRef
proc key*(waku: Waku): crypto.PrivateKey =
waku.node.key
proc logConfig(conf: WakuNodeConf) =
info "Configuration: Enabled protocols",
relay = conf.relay,
@ -121,7 +123,6 @@ proc init*(T: type Waku, srcConf: WakuNodeConf): Result[Waku, string] =
version: git_version,
conf: finalConf,
rng: rng,
key: finalConf.nodekey.get(),
node: nodeRes.get(),
dynamicBootstrapNodes: dynamicBootstrapNodesRes.get(),
)
@ -200,8 +201,13 @@ proc startWaku*(waku: ptr Waku): Future[Result[void, string]] {.async: (raises:
## Discv5
if waku[].conf.discv5Discovery or waku[].conf.discv5Only:
waku[].wakuDiscV5 = waku_discv5.setupDiscoveryV5(
waku.node.enr, waku.node.peerManager, waku.node.topicSubscriptionQueue, waku.conf,
waku.dynamicBootstrapNodes, waku.rng, waku.key,
waku.node.enr,
waku.node.peerManager,
waku.node.topicSubscriptionQueue,
waku.conf,
waku.dynamicBootstrapNodes,
waku.rng,
waku[].key(),
)
(await waku.wakuDiscV5.start()).isOkOr:

View File

@ -189,6 +189,9 @@ proc info*(node: WakuNode): WakuInfo =
let wakuInfo = WakuInfo(listenAddresses: listenStr, enrUri: enrUri)
return wakuInfo
proc key*(node: WakuNode): crypto.PrivateKey =
node.switch.peerInfo.privateKey
proc connectToNodes*(
node: WakuNode, nodes: seq[RemotePeerInfo] | seq[string], source = "api"
) {.async.} =