libp2p / go-libp2p-pubsub

The PubSub implementation for go-libp2p
https://github.com/libp2p/specs/tree/master/pubsub
Other
319 stars 185 forks source link

Multiple subscriptions for same topic in one message #390

Closed blacktemplar closed 3 years ago

blacktemplar commented 3 years ago

The subscription filters introduced in https://github.com/libp2p/go-libp2p-pubsub/pull/389 explicitly handle the case that a message contains multiple subscriptions/unsubscriptions for the same topic.

I think it would be good to spec somehow what the expected behavior is in such a situation. I would prefer a simple rule like We ignore all subscriptions except the last one for each topic. Currently the behavior of the subscription filters is somehow not very intuitive in my opinion.

Example:

Lets say a peer is not subscribed to topic A and sends a message with the following subscriptions in this order:

unsubscribe from A subscribe to A

In this case the subscription filters will ignore all the subscriptions and won't subscribe the peer to topic A despite that the last subscription in the message was a SUBSCRIBE.

aschmahmann commented 3 years ago

@vyzo do you mind taking a look?

vyzo commented 3 years ago

this is not a bug; sending multiple subscriptions and unsubscriptions on the same message is not normal behaviour. The filter does the right thing imo.

blacktemplar commented 3 years ago

So just to clarify: You say the behaviour if we have multiple subscriptions and unsubscriptions for the same topic in one message is undefined and other implementations can behave differently? Or should other implementations reimplement the go logic?

vyzo commented 3 years ago

Up to the implementation I would say, but I think the go impl logic is reasonable!