From a6007be428ccf164b59d942f5b1a4490d7a777fc Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni Date: Tue, 15 Sep 2020 19:33:18 +0900 Subject: [PATCH] avoid sending empty seqno and/or fromPeer (gossip rpc) (#364) --- libp2p/protocols/pubsub/rpc/protobuf.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libp2p/protocols/pubsub/rpc/protobuf.nim b/libp2p/protocols/pubsub/rpc/protobuf.nim index 8c94e10f2..f5a4fe621 100644 --- a/libp2p/protocols/pubsub/rpc/protobuf.nim +++ b/libp2p/protocols/pubsub/rpc/protobuf.nim @@ -68,9 +68,11 @@ proc write*(pb: var ProtoBuffer, field: int, subs: SubOpts) = proc encodeMessage*(msg: Message): seq[byte] = var pb = initProtoBuffer() - pb.write(1, msg.fromPeer) + if len(msg.fromPeer) > 0: + pb.write(1, msg.fromPeer) pb.write(2, msg.data) - pb.write(3, msg.seqno) + if len(msg.seqno) > 0: + pb.write(3, msg.seqno) for topic in msg.topicIDs: pb.write(4, topic) if len(msg.signature) > 0: