Class ContentRouting

property

{PeerId} from

property

{Uint8Array} val

Hierarchy

  • ContentRouting

Index

References

Constructors

Properties

Methods

References

CID

Re-exports CID

GetData

Re-exports GetData

Multiaddr

Re-exports Multiaddr

PeerId

Re-exports PeerId

Constructors

constructor

Properties

dht

dht: any

libp2p

libp2p: Libp2p

routers

routers: any

Methods

findProviders

  • findProviders(key: CID, options?: { maxNumProviders?: number | undefined; timeout?: number | undefined } | undefined): AsyncIterable<{ id: PeerId; multiaddrs: Multiaddr[] }>
  • Iterates over all content routers in parallel to find providers of the given key.

    Parameters

    • key: CID

      The CID key of the content to find

    • Optional options: { maxNumProviders?: number | undefined; timeout?: number | undefined } | undefined

    Returns AsyncIterable<{ id: PeerId; multiaddrs: Multiaddr[] }>

    }

get

  • get(key: Uint8Array, options?: { timeout?: number | undefined } | undefined): Promise<GetData>
  • Get the value to the given key. Times out after 1 minute by default.

    Parameters

    • key: Uint8Array
    • Optional options: { timeout?: number | undefined } | undefined

    Returns Promise<GetData>

getMany

  • getMany(key: Uint8Array, nVals: number, options?: { timeout?: number | undefined } | undefined): Promise<GetData[]>
  • Get the n values to the given key without sorting.

    Parameters

    • key: Uint8Array
    • nVals: number
    • Optional options: { timeout?: number | undefined } | undefined

    Returns Promise<GetData[]>

provide

  • provide(key: CID): Promise<void>
  • Iterates over all content routers in parallel to notify it is a provider of the given key.

    Parameters

    • key: CID

      The CID key of the content to find

    Returns Promise<void>

put

  • put(key: Uint8Array, value: Uint8Array, options?: { minPeers?: number | undefined } | undefined): Promise<void>
  • Store the given key/value pair in the DHT.

    Parameters

    • key: Uint8Array
    • value: Uint8Array
    • Optional options: { minPeers?: number | undefined } | undefined

    Returns Promise<void>