JavaScript implementation of the Kad-DHT for libp2p
$ npm i @libp2p/kad-dht
> npm i @libp2p/kad-dht
import { create } from '@libp2p/kad-dht'
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.
import { createLibp2pNode } from 'libp2p'
import { kadDHT } from '@libp2p/kad-dht'
const node = await createLibp2pNode({
dht: kadDHT()
//... other config
})
await node.start()
for await (const event of node.dht.findPeer(node.peerId)) {
console.info(event)
}
Note that you may want to supply your own peer discovery function and datastore
js-libp2p-kad-dht follows the libp2p/kad-dht spec and implements the algorithms described in the IPFS DHT documentation.
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
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.