Helia
    Preparing search index...

    Interface Routing

    interface Routing {
        cancelReprovide(key: CID, options?: AbortOptions): Promise<void>;
        findPeer(peerId: PeerId, options?: RoutingOptions): Promise<PeerInfo>;
        findProviders(cid: CID, options?: RoutingOptions): AsyncIterable<Provider>;
        get(
            key: Uint8Array,
            options?: RoutingOptions,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        getClosestPeers(
            key: Uint8Array,
            options?: RoutingOptions,
        ): AsyncIterable<PeerInfo>;
        provide(cid: CID, options?: RoutingOptions): Promise<void>;
        put(
            key: Uint8Array,
            value: Uint8Array,
            options?: RoutingOptions,
        ): Promise<void>;
    }
    Index

    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)
    • Searches the network for peer info corresponding to the passed peer id.

      Parameters

      Returns Promise<PeerInfo>

      // ...
      const peer = await peerRouting.findPeer(peerId, options)
    • Find the providers of the passed CID.

      Parameters

      Returns AsyncIterable<Provider>

      // Iterate over the providers found for the given cid
      for await (const provider of contentRouting.findProviders(cid)) {
      console.log(provider.id, provider.multiaddrs)
      }
    • 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)
      }
    • The implementation of this method should ensure that network peers know the caller can provide content that corresponds to the passed CID.

      Parameters

      Returns Promise<void>

      // ...
      await contentRouting.provide(cid)
    • Puts a value corresponding to the passed key in a way that can later be retrieved by another network peer using the get method.

      Parameters

      Returns Promise<void>

      // ...
      const key = '/key'
      const value = uint8ArrayFromString('oh hello there')

      await contentRouting.put(key, value)