mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-28 15:46:33 +00:00
feat(message): added meta attribute to waku message
This commit is contained in:
parent
43b3f1cef4
commit
4865fd4b7b
@ -21,6 +21,7 @@ proc encode*(message: WakuMessage): ProtoBuffer =
|
||||
buf.write3(2, message.contentTopic)
|
||||
buf.write3(3, message.version)
|
||||
buf.write3(10, zint64(message.timestamp))
|
||||
buf.write3(11, message.meta)
|
||||
when defined(rln):
|
||||
buf.write3(21, message.proof)
|
||||
buf.write3(31, message.ephemeral)
|
||||
@ -62,6 +63,16 @@ proc decode*(T: type WakuMessage, buffer: seq[byte]): ProtobufResult[T] =
|
||||
msg.timestamp = Timestamp(timestamp)
|
||||
|
||||
|
||||
var meta: seq[byte]
|
||||
if not ?pb.getField(11, meta):
|
||||
msg.meta = @[]
|
||||
else:
|
||||
if meta.len > MaxMetaAttrLength:
|
||||
return err(ProtobufError.invalidLengthField("meta"))
|
||||
|
||||
msg.meta = meta
|
||||
|
||||
|
||||
# Experimental: this is part of https://rfc.vac.dev/spec/17/ spec
|
||||
when defined(rln):
|
||||
var proof: seq[byte]
|
||||
|
@ -13,6 +13,8 @@ import
|
||||
../../utils/time
|
||||
|
||||
const
|
||||
MaxMetaAttrLength* = 32 # 32 bytes
|
||||
|
||||
MaxWakuMessageSize* = 1024 * 1024 # 1 Mibytes. Corresponds to PubSub default
|
||||
|
||||
|
||||
@ -30,6 +32,8 @@ type WakuMessage* = object
|
||||
payload*: seq[byte]
|
||||
# String identifier that can be used for content-based filtering.
|
||||
contentTopic*: ContentTopic
|
||||
# Application specific metadata.
|
||||
meta*: seq[byte]
|
||||
# Number to discriminate different types of payload encryption.
|
||||
# Compatibility with Whisper/WakuV1.
|
||||
version*: uint32
|
||||
|
Loading…
x
Reference in New Issue
Block a user