Skip to content

Commit

Permalink
Changes upon review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NagyZoltanPeter committed Apr 26, 2024
1 parent c418281 commit 6b41712
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions waku/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,9 @@ proc lightpushPublish*(
## Returns whether relaying was successful or not.
## `WakuMessage` should contain a `contentTopic` field for light node
## functionality.
if node.wakuLightpushClient.isNil() and node.wakuLightPush.isNil():
return err("Waku lightpush not available")

let internalPublish = proc(
node: WakuNode,
pubsubTopic: PubsubTopic,
Expand All @@ -861,9 +864,6 @@ proc lightpushPublish*(
pubsubTopic = pubsubTopic, contentTopic = message.contentTopic
return await node.wakuLightPush.handleSelfLightPushRequest(pubsubTopic, message)

if node.wakuLightpushClient.isNil() and node.wakuLightPush.isNil():
return err("waku lightpush not available")

if pubsubTopic.isSome():
debug "publishing message with lightpush",
pubsubTopic = pubsubTopic.get(),
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_api/rest/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ proc startRestServerProtocolSupport*(
## Install it either if lightpushnode (lightpush service node) is configured and client is mounted)
## or install it to be used with self-hosted lightpush service
if (conf.lightpushnode != "" and node.wakuLightpushClient != nil) or
(conf.lightpush and node.wakuLightPush != nil):
(conf.lightpush and node.wakuLightPush != nil and node.wakuRelay != nil):
let lightDiscoHandler =
if wakuDiscv5.isSome():
some(defaultDiscoveryHandler(wakuDiscv5.get(), Lightpush))
Expand Down
27 changes: 13 additions & 14 deletions waku/waku_lightpush/self_req_handler.nim
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
##
## This file is aimed to attend the requests that come directly
## from the 'self' node. It is expected to attend the store requests that
## come from REST-store endpoint when those requests don't indicate
## any store-peer address.
##
## Notice that the REST-store requests normally assume that the REST
## server is acting as a store-client. In this module, we allow that
## such REST-store node can act as store-server as well by retrieving
## its own stored messages. The typical use case for that is when
## using `nwaku-compose`, which spawn a Waku node connected to a local
## database, and the user is interested in retrieving the messages
## stored by that local store node.
##
when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}

## Notice that the REST /lightpush requests normally assume that the node
## is acting as a lightpush-client that will trigger the service provider node
## to relay the message.
## In this module, we allow that a lightpush service node (full node) can be
## triggered directly through the REST /lightpush endpoint.
## The typical use case for that is when using `nwaku-compose`,
## which spawn a full service Waku node
## that could be used also as a lightpush client, helping testing and development.

import stew/results, chronos, chronicles, std/options, metrics
import
Expand Down

0 comments on commit 6b41712

Please sign in to comment.