Skip to content
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

Merged
merged 2 commits into from
Oct 20, 2020

Conversation

blacktemplar
Copy link

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.

Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor suggestions

@@ -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) {
Copy link
Member

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()...

@@ -2265,7 +2260,7 @@ where
let mut recipient_peers = HashSet::new();

// add mesh peers
for topic in &message.topics {
for topic in &message.topic {
Copy link
Member

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

@AgeManning
Copy link
Member

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.

@blacktemplar
Copy link
Author

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.

@AgeManning AgeManning merged commit 201d533 into gossipsub-v1.1 Oct 20, 2020
@AgeManning AgeManning deleted the remove-multi-topics-for-messages branch June 15, 2021 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants