$ npm install libp2p-kad-dht
JavaScript implementation of the Kademlia DHT for libp2p, based on go-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 { 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
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.
MIT - Protocol Labs 2017
© 2010 - cnpmjs.org x YWFE | Home | YWFE