Fix wrong install of filter rest api - now installed when using filter client mode and filter client protocol is mounted correctly (#2133)

This commit is contained in:
NagyZoltanPeter 2023-10-18 11:47:47 +02:00 committed by GitHub
parent a5b1cfd024
commit 5277d122d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -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)
@ -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)
@ -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 & "/"