Skip to content

Commit

Permalink
Fix wrong install of filter rest api - now installed when using filte…
Browse files Browse the repository at this point in the history
…r client mode and filter client protocol is mounted correctly (#2133)
  • Loading branch information
NagyZoltanPeter committed Oct 18, 2023
1 parent a5b1cfd commit 5277d12
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions apps/wakunode2/app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,12 @@ proc setupProtocols(node: WakuNode,
if conf.filternode != "":
let filterNode = parsePeerInfo(conf.filternode)
if filterNode.isOk():
await node.mountFilterClient()
node.peerManager.addServicePeer(filterNode.value, WakuLegacyFilterCodec)
node.peerManager.addServicePeer(filterNode.value, WakuFilterSubscribeCodec)
try:
await node.mountFilterClient()
node.peerManager.addServicePeer(filterNode.value, WakuLegacyFilterCodec)
node.peerManager.addServicePeer(filterNode.value, WakuFilterSubscribeCodec)
except CatchableError:
return err("failed to mount waku filter client protocol: " & getCurrentExceptionMsg())
else:
return err("failed to set node waku filter peer: " & filterNode.error)

Expand Down Expand Up @@ -595,7 +598,10 @@ proc startRestServer(app: App, address: ValidIpAddress, port: Port, conf: WakuNo
installRelayApiHandlers(server.router, app.node, cache)

## Filter REST API
if conf.filter:
if conf.filternode != "" and
app.node.wakuFilterClient != nil and
app.node.wakuFilterClientLegacy != nil:

let legacyFilterCache = rest_legacy_filter_api.MessageCache.init()
rest_legacy_filter_api.installLegacyFilterRestApiHandlers(server.router, app.node, legacyFilterCache)

Expand All @@ -606,7 +612,9 @@ proc startRestServer(app: App, address: ValidIpAddress, port: Port, conf: WakuNo
installStoreApiHandlers(server.router, app.node)

## Light push API
rest_lightpush_api.installLightPushRequestHandler(server.router, app.node)
if conf.lightpushnode != "" and
app.node.wakuLightpushClient != nil:
rest_lightpush_api.installLightPushRequestHandler(server.router, app.node)

server.start()
info "Starting REST HTTP server", url = "http://" & $address & ":" & $port & "/"
Expand Down

0 comments on commit 5277d12

Please sign in to comment.