Hierarchy

  • ContentRouting

Properties

findProviders: ((cid: CID<unknown, number, number, Version>, options?: AbortOptions) => AsyncIterable<PeerInfo>)

Type declaration

    • (cid: CID<unknown, number, number, Version>, options?: AbortOptions): AsyncIterable<PeerInfo>
    • Find the providers of the passed CID.

      Example

      // Iterate over the providers found for the given cid
      for await (const provider of contentRouting.findProviders(cid)) {
      console.log(provider.id, provider.multiaddrs)
      }

      Parameters

      Returns AsyncIterable<PeerInfo>

get: ((key: Uint8Array, options?: AbortOptions) => Promise<Uint8Array>)

Type declaration

provide: ((cid: CID<unknown, number, number, Version>, options?: AbortOptions) => Promise<void>)

Type declaration

    • (cid: CID<unknown, number, number, Version>, options?: AbortOptions): Promise<void>
    • The implementation of this method should ensure that network peers know the caller can provide content that corresponds to the passed CID.

      Example

      // ...
      await contentRouting.provide(cid)

      Parameters

      Returns Promise<void>

put: ((key: Uint8Array, value: Uint8Array, options?: AbortOptions) => Promise<void>)

Type declaration

    • (key: Uint8Array, value: Uint8Array, options?: AbortOptions): Promise<void>
    • Puts a value corresponding to the passed key in a way that can later be retrieved by another network peer using the get method.

      Example

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

      await contentRouting.put(key, value)

      Parameters

      Returns Promise<void>