fix: Set `record` to the Waku Node Builder in the examples as it is required (#2328)

This commit is contained in:
Emil Ivanichkov 2024-01-05 11:00:41 +02:00 committed by GitHub
parent 7b4f4bb18c
commit 42ede93b25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -43,8 +43,18 @@ proc setupAndPublish(rng: ref HmacDrbgContext) {.async.} =
ip = parseIpAddress("0.0.0.0")
flags = CapabilitiesBitfield.init(lightpush = false, filter = false, store = false, relay = true)
var enrBuilder = EnrBuilder.init(nodeKey)
let recordRes = enrBuilder.build()
let record =
if recordRes.isErr():
error "failed to create enr record", error=recordRes.error
quit(QuitFailure)
else: recordRes.get()
var builder = WakuNodeBuilder.init()
builder.withNodeKey(nodeKey)
builder.withRecord(record)
builder.withNetworkConfigurationDetails(ip, Port(wakuPort)).tryGet()
let node = builder.build().tryGet()
@ -62,7 +72,7 @@ proc setupAndPublish(rng: ref HmacDrbgContext) {.async.} =
# assumes behind a firewall, so not care about being discoverable
let wakuDiscv5 = WakuDiscoveryV5.new(
node.rng,
node.rng,
discv5Conf,
some(node.enr),
some(node.peerManager),

View File

@ -38,8 +38,18 @@ proc setupAndSubscribe(rng: ref HmacDrbgContext) {.async.} =
ip = parseIpAddress("0.0.0.0")
flags = CapabilitiesBitfield.init(lightpush = false, filter = false, store = false, relay = true)
var enrBuilder = EnrBuilder.init(nodeKey)
let recordRes = enrBuilder.build()
let record =
if recordRes.isErr():
error "failed to create enr record", error=recordRes.error
quit(QuitFailure)
else: recordRes.get()
var builder = WakuNodeBuilder.init()
builder.withNodeKey(nodeKey)
builder.withRecord(record)
builder.withNetworkConfigurationDetails(ip, Port(wakuPort)).tryGet()
let node = builder.build().tryGet()
@ -57,7 +67,7 @@ proc setupAndSubscribe(rng: ref HmacDrbgContext) {.async.} =
# assumes behind a firewall, so not care about being discoverable
let wakuDiscv5 = WakuDiscoveryV5.new(
node.rng,
node.rng,
discv5Conf,
some(node.enr),
some(node.peerManager),