avoid sending empty seqno and/or fromPeer (gossip rpc) (#364)

This commit is contained in:
Giovanni Petrantoni 2020-09-15 19:33:18 +09:00 committed by GitHub
parent e2d46c6b53
commit a6007be428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -68,8 +68,10 @@ proc write*(pb: var ProtoBuffer, field: int, subs: SubOpts) =
proc encodeMessage*(msg: Message): seq[byte] = proc encodeMessage*(msg: Message): seq[byte] =
var pb = initProtoBuffer() var pb = initProtoBuffer()
if len(msg.fromPeer) > 0:
pb.write(1, msg.fromPeer) pb.write(1, msg.fromPeer)
pb.write(2, msg.data) pb.write(2, msg.data)
if len(msg.seqno) > 0:
pb.write(3, msg.seqno) pb.write(3, msg.seqno)
for topic in msg.topicIDs: for topic in msg.topicIDs:
pb.write(4, topic) pb.write(4, topic)