feat: expose router and mesh peers

This commit is contained in:
Richard Ramos 2024-06-28 16:15:00 -04:00
parent 8e498e9e96
commit cb2c7f7ddc
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
2 changed files with 20 additions and 0 deletions

View File

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