vacp2p / nim-libp2p

libp2p implementation in Nim
https://vacp2p.github.io/nim-libp2p/docs/
MIT License
242 stars 52 forks source link

Single topic in RPC message #1052

Closed arnetheduck closed 3 months ago

arnetheduck commented 3 months ago

Per the floodsub spec, a message has only one (mandatory) topic:

https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-message

Our code however uses a seq for topics, likely due to implementing an ancient version of the protocol no longer in use (it used to be repeated long ago - this is both wrong (when sending messages) and increases code complexity.

On incoming messages, we should require at least one topic, and if there are multiple topics in the incoming message, send to only the last one (this is how protobuf decoding of required works if there are multiple values for the same field).