feat: expose router and mesh peers (#1)

This commit is contained in:
richΛrd 2024-06-30 20:54:50 -04:00 committed by Prem Chaitanya Prathi
parent 19ffbb3a48
commit b12b0e138b
2 changed files with 20 additions and 0 deletions

View File

@ -1993,6 +1993,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

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