but it returns only the peers that are directly connected with a stream to another peer and not all peers in the network that are (indirectly) subscibed to the same topic.
The issue of peer discovery is deliberately left out of the scope of pubsub. You can leverage DHT provider records, random walks, upcoming rendezvous, or other mechanisms to discover tentative peers on a topic.
Note that gossipsub should make bonding with peers on the topic easier, thanks to the fanout gossip, as you no longer need to find a peer that is subscribed to the topic, right @vyzo?
We still use peers known to be in the topic for the fanout selection. So we do need to find peers in the topic for most effective message dissemination.
Note that we are considering adding a boostrap process to the DHT that finds peers through discovery.