mirror of https://github.com/waku-org/nwaku.git
fix: repeated fields are packed in proto3
This commit is contained in:
parent
b151672143
commit
5d2950fea2
|
@ -23,9 +23,7 @@ proc encode*(rpc: WakuMetadataRequest): ProtoBuffer =
|
||||||
var pb = initProtoBuffer()
|
var pb = initProtoBuffer()
|
||||||
|
|
||||||
pb.write3(1, rpc.clusterId)
|
pb.write3(1, rpc.clusterId)
|
||||||
|
pb.writePacked(2, rpc.shards)
|
||||||
for shard in rpc.shards:
|
|
||||||
pb.write3(2, shard)
|
|
||||||
pb.finish3()
|
pb.finish3()
|
||||||
|
|
||||||
pb
|
pb
|
||||||
|
@ -41,7 +39,7 @@ proc decode*(T: type WakuMetadataRequest, buffer: seq[byte]): ProtoResult[T] =
|
||||||
rpc.clusterId = some(clusterId.uint32)
|
rpc.clusterId = some(clusterId.uint32)
|
||||||
|
|
||||||
var shards: seq[uint64]
|
var shards: seq[uint64]
|
||||||
if ?pb.getRepeatedField(2, shards):
|
if ?pb.getPackedRepeatedField(2, shards):
|
||||||
for shard in shards:
|
for shard in shards:
|
||||||
rpc.shards.add(shard.uint32)
|
rpc.shards.add(shard.uint32)
|
||||||
|
|
||||||
|
@ -51,9 +49,7 @@ proc encode*(rpc: WakuMetadataResponse): ProtoBuffer =
|
||||||
var pb = initProtoBuffer()
|
var pb = initProtoBuffer()
|
||||||
|
|
||||||
pb.write3(1, rpc.clusterId)
|
pb.write3(1, rpc.clusterId)
|
||||||
|
pb.writePacked(2, rpc.shards)
|
||||||
for shard in rpc.shards:
|
|
||||||
pb.write3(2, shard)
|
|
||||||
pb.finish3()
|
pb.finish3()
|
||||||
|
|
||||||
pb
|
pb
|
||||||
|
@ -69,7 +65,7 @@ proc decode*(T: type WakuMetadataResponse, buffer: seq[byte]): ProtoResult[T] =
|
||||||
rpc.clusterId = some(clusterId.uint32)
|
rpc.clusterId = some(clusterId.uint32)
|
||||||
|
|
||||||
var shards: seq[uint64]
|
var shards: seq[uint64]
|
||||||
if ?pb.getRepeatedField(2, shards):
|
if ?pb.getPackedRepeatedField(2, shards):
|
||||||
for shard in shards:
|
for shard in shards:
|
||||||
rpc.shards.add(shard.uint32)
|
rpc.shards.add(shard.uint32)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue