Skip to content

Commit 660a829

Browse files
authored
fix(rln-relay): feature guard (#1373)
* fix(rln-relay): feature guard * Revert "fix(rln-relay): feature guard" This reverts commit 9344f41. * fix(rln-relay): surgically fix imports * fix(rln-relay): indents * fix(rln-relay): more usages of rln types
1 parent 3158877 commit 660a829

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

waku/v2/node/waku_node.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import
3131
../protocol/waku_filter/client as filter_client,
3232
../protocol/waku_lightpush,
3333
../protocol/waku_lightpush/client as lightpush_client,
34-
../protocol/waku_rln_relay/waku_rln_relay_types,
3534
../protocol/waku_peer_exchange,
3635
../utils/peers,
3736
../utils/wakuenr,
@@ -43,6 +42,10 @@ import
4342
./discv5/waku_discv5,
4443
./wakuswitch
4544

45+
when defined(rln):
46+
import
47+
../protocol/waku_rln_relay/waku_rln_relay_types
48+
4649
declarePublicGauge waku_version, "Waku version info (in git describe format)", ["version"]
4750
declarePublicCounter waku_node_messages, "number of messages received", ["type"]
4851
declarePublicGauge waku_node_errors, "number of wakunode errors", ["type"]
@@ -86,7 +89,8 @@ type
8689
wakuFilter*: WakuFilter
8790
wakuFilterClient*: WakuFilterClient
8891
wakuSwap*: WakuSwap
89-
wakuRlnRelay*: WakuRLNRelay
92+
when defined(rln):
93+
wakuRlnRelay*: WakuRLNRelay
9094
wakuLightPush*: WakuLightPush
9195
wakuLightpushClient*: WakuLightPushClient
9296
wakuPeerExchange*: WakuPeerExchange

waku/v2/protocol/waku_message.nim

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ import
1616
libp2p/varint
1717
import
1818
../utils/protobuf,
19-
../utils/time,
20-
./waku_rln_relay/waku_rln_relay_types
19+
../utils/time
20+
21+
when defined(rln):
22+
import
23+
./waku_rln_relay/waku_rln_relay_types
2124

2225

2326
const MaxWakuMessageSize* = 1024 * 1024 # In bytes. Corresponds to PubSub default
@@ -40,7 +43,8 @@ type WakuMessage* = object
4043
# the proof field indicates that the message is not a spam
4144
# this field will be used in the rln-relay protocol
4245
# XXX Experimental, this is part of https://rfc.vac.dev/spec/17/ spec and not yet part of WakuMessage spec
43-
proof*: RateLimitProof
46+
when defined(rln):
47+
proof*: RateLimitProof
4448
# The ephemeral field indicates if the message should
4549
# be stored. bools and uints are
4650
# equivalent in serialization of the protobuf
@@ -56,7 +60,8 @@ proc encode*(message: WakuMessage): ProtoBuffer =
5660
buf.write3(2, message.contentTopic)
5761
buf.write3(3, message.version)
5862
buf.write3(10, zint64(message.timestamp))
59-
buf.write3(21, message.proof.encode())
63+
when defined(rln):
64+
buf.write3(21, message.proof.encode())
6065
buf.write3(31, uint64(message.ephemeral))
6166
buf.finish3()
6267

@@ -75,9 +80,10 @@ proc decode*(T: type WakuMessage, buffer: seq[byte]): ProtoResult[T] =
7580
msg.timestamp = Timestamp(timestamp)
7681

7782
# XXX Experimental, this is part of https://rfc.vac.dev/spec/17/ spec
78-
var proofBytes: seq[byte]
79-
discard ?pb.getField(21, proofBytes)
80-
msg.proof = ?RateLimitProof.init(proofBytes)
83+
when defined(rln):
84+
var proofBytes: seq[byte]
85+
discard ?pb.getField(21, proofBytes)
86+
msg.proof = ?RateLimitProof.init(proofBytes)
8187

8288
var ephemeral: uint
8389
if ?pb.getField(31, ephemeral):

0 commit comments

Comments
 (0)