mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-30 00:25:45 +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(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(11, message.meta)
|
||||||
when defined(rln):
|
when defined(rln):
|
||||||
buf.write3(21, message.proof)
|
buf.write3(21, message.proof)
|
||||||
buf.write3(31, message.ephemeral)
|
buf.write3(31, message.ephemeral)
|
||||||
@ -62,6 +63,16 @@ proc decode*(T: type WakuMessage, buffer: seq[byte]): ProtobufResult[T] =
|
|||||||
msg.timestamp = Timestamp(timestamp)
|
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
|
# Experimental: this is part of https://rfc.vac.dev/spec/17/ spec
|
||||||
when defined(rln):
|
when defined(rln):
|
||||||
var proof: seq[byte]
|
var proof: seq[byte]
|
||||||
|
@ -13,6 +13,8 @@ import
|
|||||||
../../utils/time
|
../../utils/time
|
||||||
|
|
||||||
const
|
const
|
||||||
|
MaxMetaAttrLength* = 32 # 32 bytes
|
||||||
|
|
||||||
MaxWakuMessageSize* = 1024 * 1024 # 1 Mibytes. Corresponds to PubSub default
|
MaxWakuMessageSize* = 1024 * 1024 # 1 Mibytes. Corresponds to PubSub default
|
||||||
|
|
||||||
|
|
||||||
@ -30,6 +32,8 @@ type WakuMessage* = object
|
|||||||
payload*: seq[byte]
|
payload*: seq[byte]
|
||||||
# String identifier that can be used for content-based filtering.
|
# String identifier that can be used for content-based filtering.
|
||||||
contentTopic*: ContentTopic
|
contentTopic*: ContentTopic
|
||||||
|
# Application specific metadata.
|
||||||
|
meta*: seq[byte]
|
||||||
# Number to discriminate different types of payload encryption.
|
# Number to discriminate different types of payload encryption.
|
||||||
# Compatibility with Whisper/WakuV1.
|
# Compatibility with Whisper/WakuV1.
|
||||||
version*: uint32
|
version*: uint32
|
||||||
|
Loading…
x
Reference in New Issue
Block a user