libp2p
    Preparing search index...

    Interface PeerRouting

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

    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>

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