mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-05 23:43:07 +00:00
fix(wakunode2): fix main warnings and drop swap support
This commit is contained in:
parent
ab5332459e
commit
2c67a900d3
@ -471,9 +471,6 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
|||||||
let listenStr = $peerInfo.addrs[0] & "/p2p/" & $peerInfo.peerId
|
let listenStr = $peerInfo.addrs[0] & "/p2p/" & $peerInfo.peerId
|
||||||
echo &"Listening on\n {listenStr}"
|
echo &"Listening on\n {listenStr}"
|
||||||
|
|
||||||
if conf.swap:
|
|
||||||
await node.mountSwap()
|
|
||||||
|
|
||||||
if (conf.storenode != "") or (conf.store == true):
|
if (conf.storenode != "") or (conf.store == true):
|
||||||
await node.mountStore()
|
await node.mountStore()
|
||||||
|
|
||||||
|
|||||||
@ -114,13 +114,6 @@ type
|
|||||||
defaultValue: ""
|
defaultValue: ""
|
||||||
name: "filternode" }: string
|
name: "filternode" }: string
|
||||||
|
|
||||||
## Swap config
|
|
||||||
|
|
||||||
swap* {.
|
|
||||||
desc: "Enable swap protocol: true|false",
|
|
||||||
defaultValue: true
|
|
||||||
name: "swap" }: bool
|
|
||||||
|
|
||||||
## Lightpush config
|
## Lightpush config
|
||||||
|
|
||||||
lightpush* {.
|
lightpush* {.
|
||||||
|
|||||||
@ -256,13 +256,6 @@ type
|
|||||||
defaultValue: 14400 # 4 hours
|
defaultValue: 14400 # 4 hours
|
||||||
name: "filter-timeout" }: int64
|
name: "filter-timeout" }: int64
|
||||||
|
|
||||||
## Swap config
|
|
||||||
|
|
||||||
swap* {.
|
|
||||||
desc: "Enable swap protocol: true|false",
|
|
||||||
defaultValue: false
|
|
||||||
name: "swap" }: bool
|
|
||||||
|
|
||||||
## Lightpush config
|
## Lightpush config
|
||||||
|
|
||||||
lightpush* {.
|
lightpush* {.
|
||||||
|
|||||||
@ -301,7 +301,7 @@ proc initNode(conf: WakuNodeConf,
|
|||||||
discv5UdpPort = discv5UdpPort,
|
discv5UdpPort = discv5UdpPort,
|
||||||
wakuFlags = some(wakuFlags),
|
wakuFlags = some(wakuFlags),
|
||||||
))
|
))
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to create net config instance: " & getCurrentExceptionMsg())
|
return err("failed to create net config instance: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
let netConfig = netConfigOpt.get()
|
let netConfig = netConfigOpt.get()
|
||||||
@ -334,7 +334,7 @@ proc initNode(conf: WakuNodeConf,
|
|||||||
rng = rng,
|
rng = rng,
|
||||||
discv5Config = discv5Config,
|
discv5Config = discv5Config,
|
||||||
))
|
))
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to create waku discv5 instance: " & getCurrentExceptionMsg())
|
return err("failed to create waku discv5 instance: " & getCurrentExceptionMsg())
|
||||||
try:
|
try:
|
||||||
node = WakuNode.new(nodekey = nodekey,
|
node = WakuNode.new(nodekey = nodekey,
|
||||||
@ -349,7 +349,7 @@ proc initNode(conf: WakuNodeConf,
|
|||||||
agentString = some(conf.agentString),
|
agentString = some(conf.agentString),
|
||||||
peerStoreCapacity = conf.peerStoreCapacity,
|
peerStoreCapacity = conf.peerStoreCapacity,
|
||||||
rng = rng)
|
rng = rng)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to create waku node instance: " & getCurrentExceptionMsg())
|
return err("failed to create waku node instance: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
ok(node)
|
ok(node)
|
||||||
@ -365,7 +365,7 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||||||
var peerExchangeHandler = none(RoutingRecordsHandler)
|
var peerExchangeHandler = none(RoutingRecordsHandler)
|
||||||
if conf.relayPeerExchange:
|
if conf.relayPeerExchange:
|
||||||
proc handlePeerExchange(peer: PeerId, topic: string,
|
proc handlePeerExchange(peer: PeerId, topic: string,
|
||||||
peers: seq[RoutingRecordsPair]) {.gcsafe, raises: [Defect].} =
|
peers: seq[RoutingRecordsPair]) {.gcsafe.} =
|
||||||
## Handle peers received via gossipsub peer exchange
|
## Handle peers received via gossipsub peer exchange
|
||||||
# TODO: Only consider peers on pubsub topics we subscribe to
|
# TODO: Only consider peers on pubsub topics we subscribe to
|
||||||
let exchangedPeers = peers.filterIt(it.record.isSome()) # only peers with populated records
|
let exchangedPeers = peers.filterIt(it.record.isSome()) # only peers with populated records
|
||||||
@ -382,14 +382,14 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||||||
try:
|
try:
|
||||||
let pubsubTopics = conf.topics.split(" ")
|
let pubsubTopics = conf.topics.split(" ")
|
||||||
await mountRelay(node, pubsubTopics, peerExchangeHandler = peerExchangeHandler)
|
await mountRelay(node, pubsubTopics, peerExchangeHandler = peerExchangeHandler)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to mount waku relay protocol: " & getCurrentExceptionMsg())
|
return err("failed to mount waku relay protocol: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
|
|
||||||
# Keepalive mounted on all nodes
|
# Keepalive mounted on all nodes
|
||||||
try:
|
try:
|
||||||
await mountLibp2pPing(node)
|
await mountLibp2pPing(node)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to mount libp2p ping protocol: " & getCurrentExceptionMsg())
|
return err("failed to mount libp2p ping protocol: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
when defined(rln):
|
when defined(rln):
|
||||||
@ -410,16 +410,9 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await node.mountRlnRelay(rlnConf)
|
await node.mountRlnRelay(rlnConf)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to mount waku RLN relay protocol: " & getCurrentExceptionMsg())
|
return err("failed to mount waku RLN relay protocol: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
if conf.swap:
|
|
||||||
try:
|
|
||||||
await mountSwap(node)
|
|
||||||
# TODO: Set swap peer, for now should be same as store peer
|
|
||||||
except:
|
|
||||||
return err("failed to mount waku swap protocol: " & getCurrentExceptionMsg())
|
|
||||||
|
|
||||||
if conf.store:
|
if conf.store:
|
||||||
# Archive setup
|
# Archive setup
|
||||||
let messageValidator: MessageValidator = DefaultMessageValidator()
|
let messageValidator: MessageValidator = DefaultMessageValidator()
|
||||||
@ -428,7 +421,7 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||||||
# Store setup
|
# Store setup
|
||||||
try:
|
try:
|
||||||
await mountStore(node)
|
await mountStore(node)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to mount waku store protocol: " & getCurrentExceptionMsg())
|
return err("failed to mount waku store protocol: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
# TODO: Move this to storage setup phase
|
# TODO: Move this to storage setup phase
|
||||||
@ -441,14 +434,14 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||||||
mountStoreClient(node)
|
mountStoreClient(node)
|
||||||
let storenode = parseRemotePeerInfo(conf.storenode)
|
let storenode = parseRemotePeerInfo(conf.storenode)
|
||||||
node.peerManager.addServicePeer(storenode, WakuStoreCodec)
|
node.peerManager.addServicePeer(storenode, WakuStoreCodec)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to set node waku store peer: " & getCurrentExceptionMsg())
|
return err("failed to set node waku store peer: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
# NOTE Must be mounted after relay
|
# NOTE Must be mounted after relay
|
||||||
if conf.lightpush:
|
if conf.lightpush:
|
||||||
try:
|
try:
|
||||||
await mountLightPush(node)
|
await mountLightPush(node)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to mount waku lightpush protocol: " & getCurrentExceptionMsg())
|
return err("failed to mount waku lightpush protocol: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
if conf.lightpushnode != "":
|
if conf.lightpushnode != "":
|
||||||
@ -456,14 +449,14 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||||||
mountLightPushClient(node)
|
mountLightPushClient(node)
|
||||||
let lightpushnode = parseRemotePeerInfo(conf.lightpushnode)
|
let lightpushnode = parseRemotePeerInfo(conf.lightpushnode)
|
||||||
node.peerManager.addServicePeer(lightpushnode, WakuLightPushCodec)
|
node.peerManager.addServicePeer(lightpushnode, WakuLightPushCodec)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to set node waku lightpush peer: " & getCurrentExceptionMsg())
|
return err("failed to set node waku lightpush peer: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
# Filter setup. NOTE Must be mounted after relay
|
# Filter setup. NOTE Must be mounted after relay
|
||||||
if conf.filter:
|
if conf.filter:
|
||||||
try:
|
try:
|
||||||
await mountFilter(node, filterTimeout = chronos.seconds(conf.filterTimeout))
|
await mountFilter(node, filterTimeout = chronos.seconds(conf.filterTimeout))
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to mount waku filter protocol: " & getCurrentExceptionMsg())
|
return err("failed to mount waku filter protocol: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
if conf.filternode != "":
|
if conf.filternode != "":
|
||||||
@ -471,21 +464,21 @@ proc setupProtocols(node: WakuNode, conf: WakuNodeConf,
|
|||||||
await mountFilterClient(node)
|
await mountFilterClient(node)
|
||||||
let filternode = parseRemotePeerInfo(conf.filternode)
|
let filternode = parseRemotePeerInfo(conf.filternode)
|
||||||
node.peerManager.addServicePeer(filternode, WakuFilterCodec)
|
node.peerManager.addServicePeer(filternode, WakuFilterCodec)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to set node waku filter peer: " & getCurrentExceptionMsg())
|
return err("failed to set node waku filter peer: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
# waku peer exchange setup
|
# waku peer exchange setup
|
||||||
if (conf.peerExchangeNode != "") or (conf.peerExchange):
|
if (conf.peerExchangeNode != "") or (conf.peerExchange):
|
||||||
try:
|
try:
|
||||||
await mountPeerExchange(node)
|
await mountPeerExchange(node)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to mount waku peer-exchange protocol: " & getCurrentExceptionMsg())
|
return err("failed to mount waku peer-exchange protocol: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
if conf.peerExchangeNode != "":
|
if conf.peerExchangeNode != "":
|
||||||
try:
|
try:
|
||||||
let peerExchangeNode = parseRemotePeerInfo(conf.peerExchangeNode)
|
let peerExchangeNode = parseRemotePeerInfo(conf.peerExchangeNode)
|
||||||
node.peerManager.addServicePeer(peerExchangeNode, WakuPeerExchangeCodec)
|
node.peerManager.addServicePeer(peerExchangeNode, WakuPeerExchangeCodec)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to set node waku peer-exchange peer: " & getCurrentExceptionMsg())
|
return err("failed to set node waku peer-exchange peer: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
return ok()
|
return ok()
|
||||||
@ -499,7 +492,7 @@ proc startNode(node: WakuNode, conf: WakuNodeConf,
|
|||||||
# Start Waku v2 node
|
# Start Waku v2 node
|
||||||
try:
|
try:
|
||||||
await node.start()
|
await node.start()
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to start waku node: " & getCurrentExceptionMsg())
|
return err("failed to start waku node: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
# Start discv5 and connect to discovered nodes
|
# Start discv5 and connect to discovered nodes
|
||||||
@ -507,21 +500,21 @@ proc startNode(node: WakuNode, conf: WakuNodeConf,
|
|||||||
try:
|
try:
|
||||||
if not await node.startDiscv5():
|
if not await node.startDiscv5():
|
||||||
error "could not start Discovery v5"
|
error "could not start Discovery v5"
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to start waku discovery v5: " & getCurrentExceptionMsg())
|
return err("failed to start waku discovery v5: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
# Connect to configured static nodes
|
# Connect to configured static nodes
|
||||||
if conf.staticnodes.len > 0:
|
if conf.staticnodes.len > 0:
|
||||||
try:
|
try:
|
||||||
await connectToNodes(node, conf.staticnodes, "static")
|
await connectToNodes(node, conf.staticnodes, "static")
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to connect to static nodes: " & getCurrentExceptionMsg())
|
return err("failed to connect to static nodes: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
if dynamicBootstrapNodes.len > 0:
|
if dynamicBootstrapNodes.len > 0:
|
||||||
info "Connecting to dynamic bootstrap peers"
|
info "Connecting to dynamic bootstrap peers"
|
||||||
try:
|
try:
|
||||||
await connectToNodes(node, dynamicBootstrapNodes, "dynamic bootstrap")
|
await connectToNodes(node, dynamicBootstrapNodes, "dynamic bootstrap")
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to connect to dynamic bootstrap nodes: " & getCurrentExceptionMsg())
|
return err("failed to connect to dynamic bootstrap nodes: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
if conf.peerExchange:
|
if conf.peerExchange:
|
||||||
@ -551,19 +544,19 @@ when defined(waku_exp_store_resume):
|
|||||||
var remotePeer: RemotePeerInfo
|
var remotePeer: RemotePeerInfo
|
||||||
try:
|
try:
|
||||||
remotePeer = parseRemotePeerInfo(address)
|
remotePeer = parseRemotePeerInfo(address)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("invalid peer multiaddress: " & getCurrentExceptionMsg())
|
return err("invalid peer multiaddress: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await node.resume(some(@[remotePeer]))
|
await node.resume(some(@[remotePeer]))
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to resume messages history: " & getCurrentExceptionMsg())
|
return err("failed to resume messages history: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
|
|
||||||
proc startRpcServer(node: WakuNode, address: ValidIpAddress, port: uint16, portsShift: uint16, conf: WakuNodeConf): SetupResult[void] =
|
proc startRpcServer(node: WakuNode, address: ValidIpAddress, port: uint16, portsShift: uint16, conf: WakuNodeConf): SetupResult[void] =
|
||||||
try:
|
try:
|
||||||
startRpcServer(node, address, Port(port + portsShift), conf)
|
startRpcServer(node, address, Port(port + portsShift), conf)
|
||||||
except:
|
except CatchableError:
|
||||||
return err("failed to start the json-rpc server: " & getCurrentExceptionMsg())
|
return err("failed to start the json-rpc server: " & getCurrentExceptionMsg())
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user