mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-27 07:06:42 +00:00
fix(rln-relay): feature guard (#1373)
* fix(rln-relay): feature guard * Revert "fix(rln-relay): feature guard" This reverts commit 9344f41a349a8010594d3090eac1a136d47c3a4f. * 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_lightpush,
|
||||
../protocol/waku_lightpush/client as lightpush_client,
|
||||
../protocol/waku_rln_relay/waku_rln_relay_types,
|
||||
../protocol/waku_peer_exchange,
|
||||
../utils/peers,
|
||||
../utils/wakuenr,
|
||||
@ -43,6 +42,10 @@ import
|
||||
./discv5/waku_discv5,
|
||||
./wakuswitch
|
||||
|
||||
when defined(rln):
|
||||
import
|
||||
../protocol/waku_rln_relay/waku_rln_relay_types
|
||||
|
||||
declarePublicGauge waku_version, "Waku version info (in git describe format)", ["version"]
|
||||
declarePublicCounter waku_node_messages, "number of messages received", ["type"]
|
||||
declarePublicGauge waku_node_errors, "number of wakunode errors", ["type"]
|
||||
@ -86,7 +89,8 @@ type
|
||||
wakuFilter*: WakuFilter
|
||||
wakuFilterClient*: WakuFilterClient
|
||||
wakuSwap*: WakuSwap
|
||||
wakuRlnRelay*: WakuRLNRelay
|
||||
when defined(rln):
|
||||
wakuRlnRelay*: WakuRLNRelay
|
||||
wakuLightPush*: WakuLightPush
|
||||
wakuLightpushClient*: WakuLightPushClient
|
||||
wakuPeerExchange*: WakuPeerExchange
|
||||
|
@ -16,8 +16,11 @@ import
|
||||
libp2p/varint
|
||||
import
|
||||
../utils/protobuf,
|
||||
../utils/time,
|
||||
./waku_rln_relay/waku_rln_relay_types
|
||||
../utils/time
|
||||
|
||||
when defined(rln):
|
||||
import
|
||||
./waku_rln_relay/waku_rln_relay_types
|
||||
|
||||
|
||||
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
|
||||
# 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
|
||||
proof*: RateLimitProof
|
||||
when defined(rln):
|
||||
proof*: RateLimitProof
|
||||
# The ephemeral field indicates if the message should
|
||||
# be stored. bools and uints are
|
||||
# equivalent in serialization of the protobuf
|
||||
@ -56,7 +60,8 @@ proc encode*(message: WakuMessage): ProtoBuffer =
|
||||
buf.write3(2, message.contentTopic)
|
||||
buf.write3(3, message.version)
|
||||
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.finish3()
|
||||
|
||||
@ -75,9 +80,10 @@ proc decode*(T: type WakuMessage, buffer: seq[byte]): ProtoResult[T] =
|
||||
msg.timestamp = Timestamp(timestamp)
|
||||
|
||||
# XXX Experimental, this is part of https://rfc.vac.dev/spec/17/ spec
|
||||
var proofBytes: seq[byte]
|
||||
discard ?pb.getField(21, proofBytes)
|
||||
msg.proof = ?RateLimitProof.init(proofBytes)
|
||||
when defined(rln):
|
||||
var proofBytes: seq[byte]
|
||||
discard ?pb.getField(21, proofBytes)
|
||||
msg.proof = ?RateLimitProof.init(proofBytes)
|
||||
|
||||
var ephemeral: uint
|
||||
if ?pb.getField(31, ephemeral):
|
||||
|
Loading…
x
Reference in New Issue
Block a user