helia
    Preparing search index...

    Interface Router

    interface Router {
        name: string;
        cancelReprovide?(key: CID, options?: AbortOptions): Promise<void>;
        findPeer?(
            peer: CID,
            options?: RoutingOptions<RoutingFindPeerProgressEvents>,
        ): Promise<Peer>;
        findProviders?(
            cid: CID,
            options?: RoutingOptions<RoutingFindProvidersProgressEvents>,
        ): AsyncIterable<Provider>;
        get?(
            key: Uint8Array,
            options?: RoutingOptions<RoutingGetProgressEvents>,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        getClosestPeers?(
            key: Uint8Array,
            options?: RoutingOptions<RoutingGetClosestPeersProgressEvents>,
        ): AsyncIterable<Peer>;
        provide?(
            cid: CID,
            options?: RoutingOptions<RoutingProvideProgressEvents>,
        ): Promise<void>;
        put?(
            key: Uint8Array,
            value: Uint8Array,
            options?: RoutingOptions<RoutingPutProgressEvents>,
        ): Promise<void>;
    }
    Index

    Properties

    name: string

    The name of this routing implementation

    Methods

    • Helia will periodically re-provide every previously provided CID. Use this method to no longer re-provide the passed CID.

      Parameters

      Returns Promise<void>

      // ...
      await contentRouting.cancelReprovide(cid, {
      signal: AbortSignal.timeout(5_000)
      })
    • Search the network for peers that are closer to the passed key. Peer info should be yielded in ever-increasing closeness to the key.

      Returns AsyncIterable<Peer>

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