ukstv / js-libp2p-kad-dht

JavaScript implementation of the DHT for libp2p

Home Page:https://libp2p.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

js-libp2p-kad-dht

Discourse posts Build Status Coverage Status Dependency Status Bundle Size js-standard-style standard-readme compliant

JavaScript implementation of the Kademlia DHT for libp2p, based on go-libp2p-kad-dht.

Table of Contents

Install

npm

> 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

Content Routing

Peer Discovery

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.

License

Licensed under either of

Contribution

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.

About

JavaScript implementation of the DHT for libp2p

https://libp2p.io

License:Other


Languages

Language:TypeScript 99.7%Language:Go 0.3%Language:JavaScript 0.0%