3.1.0 • Published 2 years ago

@tracelabs/kad-dht v3.1.0

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
github
Last release
2 years ago

@libp2p/kad-dht

libp2p.io Discuss codecov CI

JavaScript implementation of the Kad-DHT for libp2p

Table of contents

Install

$ npm i @libp2p/kad-dht
> npm i @libp2p/kad-dht

Use in Node.js

import { create } from '@libp2p/kad-dht'

API

See https://libp2p.github.io/js-libp2p-kad-dht for the auto generated docs.

The libp2p-kad-dht module offers 3 APIs: Peer Routing, Content Routing and Peer Discovery.

Custom secondary DHT in libp2p

import { create } from '@libp2p/kad-dht'

/**
 * @param {Libp2p} libp2p
 */
async function addDHT(libp2p) {
    const customDHT = create({
        libp2p,
        protocolPrefix: '/custom'
    })
    await customDHT.start()

    return customDHT
}

Note that you may want to supply your own peer discovery function and datastore

Peer Routing

npm.io

Content Routing

npm.io

Peer Discovery

npm.io

Spec

js-libp2p-kad-dht follows the libp2p/kad-dht spec and implements the algorithms described in the IPFS DHT documentation.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

npm.io

License

Licensed under either of

Contribute

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.