Participation in peer exchange (PEX) is on a per-topic basis. We want to get PEX peers but not transactions or blocks in some relatively common situations (e.g. spinning up a brand-new node, or restarting an outdated node after hours of downtime).
The best way to implement this is to create a new topic, parallel to blocks and transactions, specifically for PEX.
Participation in peer exchange (PEX) is on a per-topic basis. We want to get PEX peers but not transactions or blocks in some relatively common situations (e.g. spinning up a brand-new node, or restarting an outdated node after hours of downtime).
The best way to implement this is to create a new topic, parallel to blocks and transactions, specifically for PEX.
This PEX topic would then somehow sync its peers.
https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub#Topic.ListPeers
This function looks promising.
https://pkg.go.dev/github.com/libp2p/go-libp2p-pubsub#PubSubRouter
If this router can be used, it has events when a peer is added or removed, so this also might be of use.
https://github.com/libp2p/go-libp2p-discovery
This library also exists for the express purpose of peer discovery. This may be the more correct method.