Closed NIC619 closed 4 years ago
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 https://github.com/libp2p/specs/pull/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.
yeah, I just merged it.
@aschmahmann The answers and linked document are really helpful. Thanks!
Had a few questions regarding the
Gossip
part of the spec and Go implementation in Gossipsub heartbeat. It says:Q1: The pseudo code is a bit confusing to me. I interpret it as: for each
topic
in bothmesh
andfanout
, get gossipssub peers from thattopic
excluding peers already inmesh
andfanout
. But in Go implementation, it's separated into two loops:mesh
andfanout
. Inmesh
loop, for eachtopic
, we get gossipssub peers from thattopic
excluding peers already inmesh
(but they could be infanout
) and vice versa forfanout
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-L522Q2: In the pseudo code, we first choose
D
gossipsub peers from thetopic
then filter our peers that's not already inmesh
andfanout
but in Go implementation peers are filtered before returning the firstcount
number of peers. https://github.com/libp2p/go-libp2p-pubsub/blob/01b9825fbee1848751d90a8469e3f5f43bac8466/gossipsub.go#L674-L694