mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-28 15:00:57 +00:00
parent
0e62e8ffa4
commit
e875dfd1d7
@ -1,6 +1,6 @@
|
|||||||
import
|
import
|
||||||
confutils, chronicles, chronos, stew/byteutils,
|
confutils, chronicles, chronos, stew/byteutils,
|
||||||
eth/[keys, p2p, async_utils],
|
eth/[keys, p2p],
|
||||||
../../waku/protocol/v1/waku_protocol,
|
../../waku/protocol/v1/waku_protocol,
|
||||||
../../waku/node/v1/waku_helpers,
|
../../waku/node/v1/waku_helpers,
|
||||||
./config_example
|
./config_example
|
||||||
@ -47,12 +47,18 @@ if config.staticnodes.len > 0:
|
|||||||
# connect to bootnodes, and/or start discovery.
|
# connect to bootnodes, and/or start discovery.
|
||||||
# This will block until first connection is made, which in this case can only
|
# 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
|
# 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.
|
# TODO: This looks a bit awkward and the API should perhaps be altered here.
|
||||||
traceAsyncErrors node.connectToNetwork(@[],
|
let connectedFut = node.connectToNetwork(@[],
|
||||||
true, # Enable listening
|
true, # Enable listening
|
||||||
false # Disable discovery (only discovery v4 is currently supported)
|
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
|
# Using a hardcoded symmetric key for encryption of the payload for the sake of
|
||||||
# simplicity.
|
# simplicity.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import
|
import
|
||||||
std/strutils,
|
std/strutils,
|
||||||
confutils, chronos, json_rpc/rpcserver, metrics, metrics/chronicles_support,
|
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/[discovery, enode, peer_pool, bootnodes, whispernodes],
|
||||||
eth/p2p/rlpx_protocols/whisper_protocol,
|
eth/p2p/rlpx_protocols/whisper_protocol,
|
||||||
../../protocol/v1/[waku_protocol, waku_bridge],
|
../../protocol/v1/[waku_protocol, waku_bridge],
|
||||||
@ -46,8 +46,13 @@ proc run(config: WakuNodeConf, rng: ref BrHmacDrbgContext) =
|
|||||||
elif config.fleet == test : setBootNodes(StatusBootNodesTest)
|
elif config.fleet == test : setBootNodes(StatusBootNodesTest)
|
||||||
else: @[]
|
else: @[]
|
||||||
|
|
||||||
traceAsyncErrors node.connectToNetwork(bootnodes, not config.noListen,
|
let connectedFut = node.connectToNetwork(bootnodes, not config.noListen,
|
||||||
config.discovery)
|
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:
|
if not config.bootnodeOnly:
|
||||||
# Optionally direct connect with a set of nodes
|
# Optionally direct connect with a set of nodes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user