feat: expose router and mesh peers (#1)

This commit is contained in:
richΛrd 2024-06-30 20:54:50 -04:00 committed by Igor Sirotin
parent b50197ee8b
commit ab817a0cb1
No known key found for this signature in database
GPG Key ID: 0EABBCB40CB9AD4A
2 changed files with 20 additions and 0 deletions

View File

@ -2133,6 +2133,22 @@ func (gs *GossipSubRouter) getPeers(topic string, count int, filter func(peer.ID
return peers
}
func (gs *GossipSubRouter) MeshPeers(topic string) []peer.ID {
peers, ok := gs.mesh[topic]
if !ok {
return nil
}
result := make([]peer.ID, len(peers))
i := 0
for p := range peers {
result[i] = p
i++
}
return result
}
// WithDefaultTagTracer returns the tag tracer of the GossipSubRouter as a PubSub option.
// This is useful for cases where the GossipSubRouter is instantiated externally, and is
// injected into the GossipSub constructor as a dependency. This allows the tag tracer to be

View File

@ -1440,3 +1440,7 @@ type addRelayReq struct {
topic string
resp chan RelayCancelFunc
}
func (p *PubSub) Router() PubSubRouter {
return p.rt
}