interface KadDHTInit {
    allowQueryWithZeroPeers?: boolean;
    clientMode?: boolean;
    datastorePrefix?: string;
    initialQuerySelfInterval?: number;
    kBucketSize?: number;
    kBucketSplitThreshold?: number;
    logPrefix?: string;
    maxInboundStreams?: number;
    maxOutboundStreams?: number;
    metricsPrefix?: string;
    networkDialTimeout?: Omit<AdaptiveTimeoutInit, "metricsName" | "metrics">;
    pingNewContactConcurrency?: number;
    pingNewContactMaxQueueSize?: number;
    pingNewContactTimeout?: Omit<AdaptiveTimeoutInit, "metricsName" | "metrics">;
    pingOldContactConcurrency?: number;
    pingOldContactMaxQueueSize?: number;
    pingOldContactTimeout?: Omit<AdaptiveTimeoutInit, "metricsName" | "metrics">;
    prefixLength?: number;
    protocol?: string;
    providers?: ProvidersInit;
    querySelfInterval?: number;
    reprovide?: ReProvideInit;
    selectors?: Selectors;
    validators?: Validators;
    peerInfoMapper?(peer): PeerInfo;
}

Properties

allowQueryWithZeroPeers?: boolean

After startup by default all queries will be paused until the initial self-query has run and there are some peers in the routing table.

Pass true here to disable this behaviour.

Default

false
clientMode?: boolean

If true, only ever be a DHT client. If false, be a DHT client until told to be a DHT server via setMode.

Default

false
datastorePrefix?: string

The datastore prefix to use

Default

"/dht"
initialQuerySelfInterval?: number

During startup we run the self-query at a shorter interval to ensure the containing node can respond to queries quickly. Set this interval here in ms.

Default

1000
kBucketSize?: number

How many peers to store in each kBucket. Once there are more than this number of peers for a given prefix in a kBucket, the node will start to ping existing peers to see if they are still online - if they are offline they will be evicted and the new peer added.

Default

20
kBucketSplitThreshold?: number

The threshold at which a kBucket will be split into two smaller kBuckets.

KBuckets will not be split once the maximum trie depth is reached (controlled by the prefixLength option) so one can replicate go-libp2p's accelerated DHT client by (for example) setting kBucketSize to Infinity and kBucketSplitThreshold to 20.

Default

kBucketSize
logPrefix?: string

The logging prefix to use

Default

"libp2p:kad-dht"
maxInboundStreams?: number

How many parallel incoming streams to allow on the DHT protocol per connection

Default

32
maxOutboundStreams?: number

How many parallel outgoing streams to allow on the DHT protocol per connection

Default

64
metricsPrefix?: string

The metrics prefix to use

Default

"libp2p_kad_dht"
networkDialTimeout?: Omit<AdaptiveTimeoutInit, "metricsName" | "metrics">

Dynamic network timeout settings for sending messages to peers

pingNewContactConcurrency?: number

How many peers to ping in parallel when deciding if they should be added to the routing table or not

Default

10
pingNewContactMaxQueueSize?: number

How long the queue to ping peers is allowed to grow

Default

100
pingNewContactTimeout?: Omit<AdaptiveTimeoutInit, "metricsName" | "metrics">

Settings for how long to wait in ms when pinging DHT peers to decide if they should be added to the routing table or not.

pingOldContactConcurrency?: number

How many peers to ping in parallel when deciding if they should be evicted from the routing table or not

Default

10
pingOldContactMaxQueueSize?: number

How long the queue to ping peers is allowed to grow

Default

100
pingOldContactTimeout?: Omit<AdaptiveTimeoutInit, "metricsName" | "metrics">

Settings for how long to wait in ms when pinging DHT peers to decide if they should be evicted from the routing table or not.

prefixLength?: number

How many bits of the KAD-ID of peers to use when creating the routing table.

The routing table is a binary trie with peers stored in the leaf nodes. The larger this number gets, the taller the trie can grow and the more peers can be stored.

Storing more peers means fewer lookups (and network operations) are needed to locate a certain peer, but also that more memory is consumed.

Default

32
protocol?: string

The network protocol to use

Default

"/ipfs/kad/1.0.0"
providers?: ProvidersInit

Initialization options for the Providers component

querySelfInterval?: number

How often to query our own PeerId in order to ensure we have a good view on the KAD address space local to our PeerId

reprovide?: ReProvideInit

Initialization options for the Reprovider component

selectors?: Selectors

Record selectors

validators?: Validators

Record validators

Methods