libp2p
    Preparing search index...

    Interface KadDHTInit

    interface KadDHTInit {
        allowQueryWithZeroPeers?: boolean;
        alpha?: number;
        clientMode?: boolean;
        datastorePrefix?: string;
        disjointPaths?: number;
        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): PeerInfo;
    }
    Index

    Properties

    allowQueryWithZeroPeers?: boolean

    After startup by default all queries will be paused until there is at least one peer in the routing table.

    Pass true here to disable this behavior.

    false
    
    alpha?: number

    How many peers are queried in parallel during a query.

    3
    
    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.

    In general this should be left as the default because server mode will be selected automatically when libp2p establishes that the current node has a publicly dialable address.

    The exception to this is LAN-only DHT (e.g. for testing purposes) where it is safe to assume that the current node is dialable.

    false
    
    datastorePrefix?: string

    The datastore prefix to use

    "/dht"
    
    disjointPaths?: number

    How many disjoint paths are used during a query

    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.

    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.

    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.

    kBucketSize
    
    logPrefix?: string

    The logging prefix to use

    "libp2p:kad-dht"
    
    maxInboundStreams?: number

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

    32
    
    maxOutboundStreams?: number

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

    64
    
    metricsPrefix?: string

    The metrics prefix to use

    "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

    10
    
    pingNewContactMaxQueueSize?: number

    How long the queue to ping peers is allowed to grow

    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

    10
    
    pingOldContactMaxQueueSize?: number

    How long the queue to ping peers is allowed to grow

    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 and more CPU while responding to queries (e.g. with more peers in the table sorting the closest peers becomes more expensive) and CPU/network during table maintenance (e.g. checking peers are still online).

    The larger this value, the more prefix bits must be the same for a peer to be stored in a KAD bucket, so the fewer nodes that bucket is likely to contain.

    The total number of peers in the table is a factor of prefixLength and kBucketSize:

    (2 ^ prefixLength) * kBucketSize
    
    6
    
    protocol?: string

    The network protocol to use

    "/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