mirror of https://github.com/waku-org/nwaku.git
fix(rln-relay): feature guard (#1373)
* fix(rln-relay): feature guard
* Revert "fix(rln-relay): feature guard"
This reverts commit 9344f41a34
.
* fix(rln-relay): surgically fix imports
* fix(rln-relay): indents
* fix(rln-relay): more usages of rln types
This commit is contained in:
parent
97eaa6919b
commit
2336522d7f
|
@ -31,7 +31,6 @@ import
|
||||||
../protocol/waku_filter/client as filter_client,
|
../protocol/waku_filter/client as filter_client,
|
||||||
../protocol/waku_lightpush,
|
../protocol/waku_lightpush,
|
||||||
../protocol/waku_lightpush/client as lightpush_client,
|
../protocol/waku_lightpush/client as lightpush_client,
|
||||||
../protocol/waku_rln_relay/waku_rln_relay_types,
|
|
||||||
../protocol/waku_peer_exchange,
|
../protocol/waku_peer_exchange,
|
||||||
../utils/peers,
|
../utils/peers,
|
||||||
../utils/wakuenr,
|
../utils/wakuenr,
|
||||||
|
@ -43,6 +42,10 @@ import
|
||||||
./discv5/waku_discv5,
|
./discv5/waku_discv5,
|
||||||
./wakuswitch
|
./wakuswitch
|
||||||
|
|
||||||
|
when defined(rln):
|
||||||
|
import
|
||||||
|
../protocol/waku_rln_relay/waku_rln_relay_types
|
||||||
|
|
||||||
declarePublicGauge waku_version, "Waku version info (in git describe format)", ["version"]
|
declarePublicGauge waku_version, "Waku version info (in git describe format)", ["version"]
|
||||||
declarePublicCounter waku_node_messages, "number of messages received", ["type"]
|
declarePublicCounter waku_node_messages, "number of messages received", ["type"]
|
||||||
declarePublicGauge waku_node_errors, "number of wakunode errors", ["type"]
|
declarePublicGauge waku_node_errors, "number of wakunode errors", ["type"]
|
||||||
|
@ -86,7 +89,8 @@ type
|
||||||
wakuFilter*: WakuFilter
|
wakuFilter*: WakuFilter
|
||||||
wakuFilterClient*: WakuFilterClient
|
wakuFilterClient*: WakuFilterClient
|
||||||
wakuSwap*: WakuSwap
|
wakuSwap*: WakuSwap
|
||||||
wakuRlnRelay*: WakuRLNRelay
|
when defined(rln):
|
||||||
|
wakuRlnRelay*: WakuRLNRelay
|
||||||
wakuLightPush*: WakuLightPush
|
wakuLightPush*: WakuLightPush
|
||||||
wakuLightpushClient*: WakuLightPushClient
|
wakuLightpushClient*: WakuLightPushClient
|
||||||
wakuPeerExchange*: WakuPeerExchange
|
wakuPeerExchange*: WakuPeerExchange
|
||||||
|
|
|
@ -16,8 +16,11 @@ import
|
||||||
libp2p/varint
|
libp2p/varint
|
||||||
import
|
import
|
||||||
../utils/protobuf,
|
../utils/protobuf,
|
||||||
../utils/time,
|
../utils/time
|
||||||
./waku_rln_relay/waku_rln_relay_types
|
|
||||||
|
when defined(rln):
|
||||||
|
import
|
||||||
|
./waku_rln_relay/waku_rln_relay_types
|
||||||
|
|
||||||
|
|
||||||
const MaxWakuMessageSize* = 1024 * 1024 # In bytes. Corresponds to PubSub default
|
const MaxWakuMessageSize* = 1024 * 1024 # In bytes. Corresponds to PubSub default
|
||||||
|
@ -40,7 +43,8 @@ type WakuMessage* = object
|
||||||
# the proof field indicates that the message is not a spam
|
# the proof field indicates that the message is not a spam
|
||||||
# this field will be used in the rln-relay protocol
|
# this field will be used in the rln-relay protocol
|
||||||
# XXX Experimental, this is part of https://rfc.vac.dev/spec/17/ spec and not yet part of WakuMessage spec
|
# XXX Experimental, this is part of https://rfc.vac.dev/spec/17/ spec and not yet part of WakuMessage spec
|
||||||
proof*: RateLimitProof
|
when defined(rln):
|
||||||
|
proof*: RateLimitProof
|
||||||
# The ephemeral field indicates if the message should
|
# The ephemeral field indicates if the message should
|
||||||
# be stored. bools and uints are
|
# be stored. bools and uints are
|
||||||
# equivalent in serialization of the protobuf
|
# equivalent in serialization of the protobuf
|
||||||
|
@ -56,7 +60,8 @@ proc encode*(message: WakuMessage): ProtoBuffer =
|
||||||
buf.write3(2, message.contentTopic)
|
buf.write3(2, message.contentTopic)
|
||||||
buf.write3(3, message.version)
|
buf.write3(3, message.version)
|
||||||
buf.write3(10, zint64(message.timestamp))
|
buf.write3(10, zint64(message.timestamp))
|
||||||
buf.write3(21, message.proof.encode())
|
when defined(rln):
|
||||||
|
buf.write3(21, message.proof.encode())
|
||||||
buf.write3(31, uint64(message.ephemeral))
|
buf.write3(31, uint64(message.ephemeral))
|
||||||
buf.finish3()
|
buf.finish3()
|
||||||
|
|
||||||
|
@ -75,9 +80,10 @@ proc decode*(T: type WakuMessage, buffer: seq[byte]): ProtoResult[T] =
|
||||||
msg.timestamp = Timestamp(timestamp)
|
msg.timestamp = Timestamp(timestamp)
|
||||||
|
|
||||||
# XXX Experimental, this is part of https://rfc.vac.dev/spec/17/ spec
|
# XXX Experimental, this is part of https://rfc.vac.dev/spec/17/ spec
|
||||||
var proofBytes: seq[byte]
|
when defined(rln):
|
||||||
discard ?pb.getField(21, proofBytes)
|
var proofBytes: seq[byte]
|
||||||
msg.proof = ?RateLimitProof.init(proofBytes)
|
discard ?pb.getField(21, proofBytes)
|
||||||
|
msg.proof = ?RateLimitProof.init(proofBytes)
|
||||||
|
|
||||||
var ephemeral: uint
|
var ephemeral: uint
|
||||||
if ?pb.getField(31, ephemeral):
|
if ?pb.getField(31, ephemeral):
|
||||||
|
|
Loading…
Reference in New Issue