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

Questions regarding Gossip part in Gossipsub heartbeat #231

Closed
NIC619 opened this issue Dec 4, 2019 · 3 comments
Closed

Questions regarding Gossip part in Gossipsub heartbeat #231

NIC619 opened this issue Dec 4, 2019 · 3 comments

Comments

@NIC619
Copy link

NIC619 commented Dec 4, 2019

Had a few questions regarding the Gossip part of the spec and Go implementation in Gossipsub heartbeat.
It says:

Gossip is emitted by selecting peers for each topic that are not already part of the mesh:

for each topic in mesh+fanout:
  let mids be mcache.window[topic]
  if mids is not empty:
    select D peers from peers.gossipsub[topic]
    for each peer not in mesh[topic] or fanout[topic]
      emit IHAVE(mids)

shift the mcache

Q1:
The pseudo code is a bit confusing to me. I interpret it as: for each topic in both mesh and fanout, get gossipssub peers from that topic excluding peers already in mesh and fanout.
But in Go implementation, it's separated into two loops: mesh and fanout.
In mesh loop, for each topic, we get gossipssub peers from that topic excluding peers already in mesh (but they could be in fanout) and vice versa for fanout loop.
https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L482-L484
https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L520-L522

Q2:
In the pseudo code, we first choose D gossipsub peers from the topic then filter our peers that's not already in mesh and fanout but in Go implementation peers are filtered before returning the first count number of peers.
https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L674-L694

@aschmahmann
Copy link
Contributor

Q1: You're not able to have mesh and fanout peers for the same topic simultaneously. fanout is for when we're not subscribed, mesh is for when we are subscribed.

Q2: Yes, that was a relatively recent change in the Go implementation. There is a spec PR to update the spec at #219. @vyzo is that PR ready to merge now?

@NIC619 Just a heads up that if you haven't checked out https://docs.libp2p.io/concepts/publish-subscribe/ yet that you might find it useful. It's got some really nice descriptions and breakdown of how the protocol works.

@vyzo
Copy link
Contributor

vyzo commented Dec 4, 2019

yeah, I just merged it.

@NIC619
Copy link
Author

NIC619 commented Dec 5, 2019

@aschmahmann The answers and linked document are really helpful. Thanks!

@NIC619 NIC619 closed this as completed Dec 5, 2019
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

No branches or pull requests

3 participants