mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-28 06:50:56 +00:00
parent
0e62e8ffa4
commit
e875dfd1d7
@ -1,6 +1,6 @@
|
||||
import
|
||||
confutils, chronicles, chronos, stew/byteutils,
|
||||
eth/[keys, p2p, async_utils],
|
||||
eth/[keys, p2p],
|
||||
../../waku/protocol/v1/waku_protocol,
|
||||
../../waku/node/v1/waku_helpers,
|
||||
./config_example
|
||||
@ -47,12 +47,18 @@ if config.staticnodes.len > 0:
|
||||
# connect to bootnodes, and/or start discovery.
|
||||
# This will block until first connection is made, which in this case can only
|
||||
# happen if we directly connect to nodes (step above) or if an incoming
|
||||
# connection occurs, which is why we use `traceAsyncErrors` instead of `await`.
|
||||
# connection occurs, which is why we use a callback to exit on errors instead of
|
||||
# using `await`.
|
||||
# TODO: This looks a bit awkward and the API should perhaps be altered here.
|
||||
traceAsyncErrors node.connectToNetwork(@[],
|
||||
let connectedFut = node.connectToNetwork(@[],
|
||||
true, # Enable listening
|
||||
false # Disable discovery (only discovery v4 is currently supported)
|
||||
)
|
||||
connectedFut.callback = proc(data: pointer) {.gcsafe.} =
|
||||
{.gcsafe.}:
|
||||
if connectedFut.failed:
|
||||
fatal "connectToNetwork failed", msg = connectedFut.readError.msg
|
||||
quit(1)
|
||||
|
||||
# Using a hardcoded symmetric key for encryption of the payload for the sake of
|
||||
# simplicity.
|
||||
|
@ -1,7 +1,7 @@
|
||||
import
|
||||
std/strutils,
|
||||
confutils, chronos, json_rpc/rpcserver, metrics, metrics/chronicles_support,
|
||||
eth/[keys, p2p, async_utils], eth/common/utils,
|
||||
eth/[keys, p2p], eth/common/utils,
|
||||
eth/p2p/[discovery, enode, peer_pool, bootnodes, whispernodes],
|
||||
eth/p2p/rlpx_protocols/whisper_protocol,
|
||||
../../protocol/v1/[waku_protocol, waku_bridge],
|
||||
@ -46,8 +46,13 @@ proc run(config: WakuNodeConf, rng: ref BrHmacDrbgContext) =
|
||||
elif config.fleet == test : setBootNodes(StatusBootNodesTest)
|
||||
else: @[]
|
||||
|
||||
traceAsyncErrors node.connectToNetwork(bootnodes, not config.noListen,
|
||||
let connectedFut = node.connectToNetwork(bootnodes, not config.noListen,
|
||||
config.discovery)
|
||||
connectedFut.callback = proc(data: pointer) {.gcsafe.} =
|
||||
{.gcsafe.}:
|
||||
if connectedFut.failed:
|
||||
fatal "connectToNetwork failed", msg = connectedFut.readError.msg
|
||||
quit(1)
|
||||
|
||||
if not config.bootnodeOnly:
|
||||
# Optionally direct connect with a set of nodes
|
||||
|
Loading…
x
Reference in New Issue
Block a user