Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface API<OptionExtension>

Type parameters

  • OptionExtension = {}

Hierarchy

  • API

Index

Methods

  • Query the DHT for all multiaddresses associated with a PeerId.

    example
    const info = await ipfs.dht.findPeer('QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt')

    console.log(info.id)
    // QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt

    info.addrs.forEach(addr => console.log(addr.toString()))
    // '/ip4/147.75.94.115/udp/4001/quic'
    // '/ip6/2604:1380:3000:1f00::1/udp/4001/quic'
    // '/dnsaddr/bootstrap.libp2p.io'
    // '/ip6/2604:1380:3000:1f00::1/tcp/4001'
    // '/ip4/147.75.94.115/tcp/4001'

    Parameters

    • peerId: string
    • Optional options: AbortOptions & OptionExtension

    Returns AsyncIterable<QueryEvent>

  • Find peers in the DHT that can provide a specific value, given a CID.

    example
    const providers = ipfs.dht.findProvs('QmdPAhQRxrDKqkGPvQzBvjYe3kU8kiEEAd2J6ETEamKAD9')
    for await (const provider of providers) {
    console.log(provider.id.toString())
    }

    Parameters

    Returns AsyncIterable<QueryEvent>

  • Given a key, query the DHT for its best value.

    Parameters

    • key: string | Uint8Array
    • Optional options: AbortOptions & OptionExtension

    Returns AsyncIterable<QueryEvent>

  • put(key: string | Uint8Array, value: Uint8Array, options?: AbortOptions & OptionExtension): AsyncIterable<QueryEvent>
  • Write a key/value pair to the DHT.

    Given a key of the form /foo/bar and a value of any form, this will write that value to the DHT with that key.

    Parameters

    • key: string | Uint8Array
    • value: Uint8Array
    • Optional options: AbortOptions & OptionExtension

    Returns AsyncIterable<QueryEvent>

  • Find the closest peers to a given PeerId or CID, by querying the DHT.

    Parameters

    • peerId: string | CID
    • Optional options: AbortOptions & OptionExtension

    Returns AsyncIterable<QueryEvent>

Generated using TypeDoc