use peer-exchange to discover mix nodes

This commit is contained in:
Prem Chaitanya Prathi 2025-07-28 22:51:48 +05:30
parent c5d76a12b5
commit bff3179906
2 changed files with 18 additions and 10 deletions

View File

@ -463,7 +463,14 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
quit(QuitFailure)
node.mountMetadata(conf.clusterId).isOkOr:
error "failed to mount waku metadata protocol: ", err = error
quit 1
quit(QuitFailure)
try:
await node.mountPeerExchange()
except CatchableError:
error "failed to mount waku peer-exchange protocol",
error = getCurrentExceptionMsg()
quit(QuitFailure)
let (mixPrivKey, mixPubKey) = generateKeyPair().valueOr:
error "failed to generate mix key pair", error = error
@ -476,14 +483,6 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
await node.start()
node.peerManager.start()
node.startPeerExchangeLoop()
while node.getMixNodePoolSize() < 3:
info "waiting for mix nodes to be discovered",
currentpoolSize = node.getMixNodePoolSize()
await sleepAsync(1000)
notice "ready tp publish with mix node pool size ",
currentpoolSize = node.getMixNodePoolSize()
#[ if conf.rlnRelayCredPath == "":
raise newException(ConfigurationError, "rln-relay-cred-path MUST be passed")
@ -636,7 +635,16 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
else:
error "LightPushClient not mounted. Couldn't parse conf.serviceNode",
error = peerInfo.error
# TODO: Loop faster and also switch to rendezvous
node.startPeerExchangeLoop()
while node.getMixNodePoolSize() < 3:
info "waiting for mix nodes to be discovered",
currentpoolSize = node.getMixNodePoolSize()
await sleepAsync(1000)
notice "ready tp publish with mix node pool size ",
currentpoolSize = node.getMixNodePoolSize()
echo "ready to publish messages now"
# Subscribe to a topic, if relay is mounted
#[ if conf.relay:
proc handler(topic: PubsubTopic, msg: WakuMessage): Future[void] {.async, gcsafe.} =

View File

@ -110,7 +110,7 @@ type
## Store config
store* {.
desc: "Enable store protocol: true|false", defaultValue: true, name: "store"
desc: "Enable store protocol: true|false", defaultValue: false, name: "store"
.}: bool
storenode* {.