mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 08:23:08 +00:00
Updates the type of the proof field of wakumessage to RateLimitProof (#893)
* permanently changes the wakumessage proof field to RateLimitProof * updates an old comment
This commit is contained in:
parent
e6fdbdb42a
commit
2d6a2bec47
@ -11,9 +11,8 @@
|
|||||||
import
|
import
|
||||||
libp2p/protobuf/minprotobuf,
|
libp2p/protobuf/minprotobuf,
|
||||||
libp2p/varint,
|
libp2p/varint,
|
||||||
../utils/time
|
../utils/time,
|
||||||
when defined(rln):
|
waku_rln_relay/waku_rln_relay_types
|
||||||
import waku_rln_relay/waku_rln_relay_types
|
|
||||||
|
|
||||||
const
|
const
|
||||||
MaxWakuMessageSize* = 1024 * 1024 # In bytes. Corresponds to PubSub default
|
MaxWakuMessageSize* = 1024 * 1024 # In bytes. Corresponds to PubSub default
|
||||||
@ -30,10 +29,8 @@ type
|
|||||||
# 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
|
||||||
when defined(rln):
|
proof*: RateLimitProof
|
||||||
proof*: RateLimitProof
|
|
||||||
else:
|
|
||||||
proof*: seq[byte]
|
|
||||||
|
|
||||||
|
|
||||||
# Encoding and decoding -------------------------------------------------------
|
# Encoding and decoding -------------------------------------------------------
|
||||||
@ -49,14 +46,11 @@ proc init*(T: type WakuMessage, buffer: seq[byte]): ProtoResult[T] =
|
|||||||
discard ? pb.getField(10, timestamp)
|
discard ? pb.getField(10, timestamp)
|
||||||
msg.timestamp = Timestamp(timestamp)
|
msg.timestamp = Timestamp(timestamp)
|
||||||
|
|
||||||
# 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
|
||||||
when defined(rln):
|
var proofBytes: seq[byte]
|
||||||
var proofBytes: seq[byte]
|
discard ? pb.getField(21, proofBytes)
|
||||||
discard ? pb.getField(21, proofBytes)
|
msg.proof = ? RateLimitProof.init(proofBytes)
|
||||||
msg.proof = ? RateLimitProof.init(proofBytes)
|
|
||||||
else:
|
|
||||||
discard ? pb.getField(21, msg.proof)
|
|
||||||
|
|
||||||
ok(msg)
|
ok(msg)
|
||||||
|
|
||||||
proc encode*(message: WakuMessage): ProtoBuffer =
|
proc encode*(message: WakuMessage): ProtoBuffer =
|
||||||
@ -66,7 +60,5 @@ proc encode*(message: WakuMessage): ProtoBuffer =
|
|||||||
result.write(2, message.contentTopic)
|
result.write(2, message.contentTopic)
|
||||||
result.write(3, message.version)
|
result.write(3, message.version)
|
||||||
result.write(10, zint64(message.timestamp))
|
result.write(10, zint64(message.timestamp))
|
||||||
when defined(rln):
|
result.write(21, message.proof.encode())
|
||||||
result.write(21, message.proof.encode())
|
|
||||||
else:
|
|
||||||
result.write(21, message.proof)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user