mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 10:32:14 +00:00
fix: look for final peer event instead of peer response (#1092)
`FINAL_PEER` means we found the peer, `PEER_RESPONSE` means a peer responded to our query.
This commit is contained in:
parent
79b3cfc6ad
commit
d2b7ec0f6b
@ -27,12 +27,8 @@ class DHTPeerRouting {
|
||||
*/
|
||||
async findPeer (peerId, options = {}) {
|
||||
for await (const event of this._dht.findPeer(peerId, options)) {
|
||||
if (event.name === 'PEER_RESPONSE') {
|
||||
const peer = event.closer.find(peerData => peerData.id.equals(peerId))
|
||||
|
||||
if (peer) {
|
||||
return peer
|
||||
}
|
||||
if (event.name === 'FINAL_PEER') {
|
||||
return event.peer
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user