-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove support for multi-topic messages #73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor suggestions
protocols/gossipsub/src/mcache.rs
Outdated
@@ -126,7 +126,7 @@ impl<T> MessageCache<T> { | |||
let mut found_entries: Vec<MessageId> = entries | |||
.iter() | |||
.filter_map(|entry| { | |||
if entry.topics.iter().any(|t| t == topic) { | |||
if entry.topic.iter().any(|t| t == topic) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and a few others could just be an if let Some()...
protocols/gossipsub/src/behaviour.rs
Outdated
@@ -2265,7 +2260,7 @@ where | |||
let mut recipient_peers = HashSet::new(); | |||
|
|||
// add mesh peers | |||
for topic in &message.topics { | |||
for topic in &message.topic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let Some()
seems more readable to me
Although go hasn't done it yet. From the PR it seems they plan to do it in the near future. I think it would be good for us to just drop the optional and make a single topic compulsory for each message. I think it might make our code a bit cleaner and we dont have to worry about the case of messages flying around without topics. |
Ok the latest changes make the topic required. Note that we handle now incoming messages that don't contain a topic as invalid. This also implicitly resolves your other comments. |
Removes support for multi topic messages while staying compatible to the old message format.
If multiple topics are specified in a message only the last one is considered. See also libp2p/go-libp2p-pubsub#388.