interface PeerRouting {
    findPeer(peerId, options?): Promise<PeerInfo>;
    getClosestPeers(key, options?): AsyncIterable<PeerInfo>;
}

Methods

  • Search the network for peers that are closer to the passed key. Peer info should be yielded in ever-increasing closeness to the key.

    Parameters

    Returns AsyncIterable<PeerInfo>

    Example

    // Iterate over the closest peers found for the given key
    for await (const peer of peerRouting.getClosestPeers(key)) {
    console.log(peer.id, peer.multiaddrs)
    }