chore: improving get_peer_ids_by_protocol by returning the available protocols of connected peers (#3109)

This commit is contained in:
gabrielmer 2024-10-11 13:58:29 +03:00 committed by GitHub
parent 78759f6e52
commit ed0ee5be20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,8 +81,11 @@ proc process*(
return ok(peerIDs)
of GET_PEER_IDS_BY_PROTOCOL:
## returns a comma-separated string of peerIDs that mount the given protocol
let (inPeers, outPeers) = waku.node.peerManager.connectedPeers($self[].protocol)
let allPeerIDs = inPeers & outPeers
return ok(allPeerIDs.join(","))
let connectedPeers = waku.node.peerManager.wakuPeerStore
.peers($self[].protocol)
.filterIt(it.connectedness == Connected)
.mapIt($it.peerId)
.join(",")
return ok(connectedPeers)
return ok("")