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

Send IDONTWANT prior to publish #386

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

StefanBratanov
Copy link
Collaborator

Send IDONTWANT on each publish. Maybe we need to add some filtering to make it more selective, but not sure?

I removed filtering out excluding the receivedFrom peer when we are sending IDONTWANT on inbound messages. Think it simplifies the flow and could help in some cases, where receivedFrom may send the same message twice.

fixes #383

Copy link
Collaborator

@Nashatyrev Nashatyrev left a comment

Choose a reason for hiding this comment

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

LGTM, I'd just leave the peer exclusion

@@ -610,15 +611,14 @@ open class GossipRouter(
enqueueIwant(peer, messageIds)
}

private fun iDontWant(msg: PubsubMessage, receivedFrom: PeerHandler) {
private fun iDontWant(msg: PubsubMessage) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

TBH I would leave the excluded peer. We are saving one IDONTWANT message for free.

Suggested change
private fun iDontWant(msg: PubsubMessage) {
private fun iDontWant(msg: PubsubMessage?) {

if (!this.protocol.supportsIDontWant()) return
if (msg.protobufMessage.data.size() < params.iDontWantMinMessageSizeThreshold) return
// we need to send IDONTWANT messages to mesh peers immediately in order for them to have an effect
msg.topics
.mapNotNull { mesh[it] }
.flatten()
.distinct()
.minus(receivedFrom)
Copy link
Collaborator

Choose a reason for hiding this comment

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

            .minus(setOfNotNull(receivedFrom))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I was looking for a nice way to add it back. This one seems good. Implemented.

@StefanBratanov StefanBratanov enabled auto-merge (squash) October 18, 2024 10:15
@StefanBratanov StefanBratanov merged commit a00728e into libp2p:develop Oct 18, 2024
2 checks passed
@StefanBratanov StefanBratanov deleted the send_idont_want branch October 21, 2024 00:00
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.

Gossip: send IDONTWANT selectively prior to publish
2 participants