Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 941 Bytes

README.md

File metadata and controls

30 lines (22 loc) · 941 Bytes

Kadem CI

An implementation of the BitTorrent DHT (Kademlia).

Supports:

  • BEP-42 with sse4_crc32 optional dependency.
  • BEP-44 with ed25519-supercop optional dependency.

Usage

npm install kadem

import DHT from 'kadem';

// load DHT from stored state file; if it doesn't
// exist or is not provided it'll bootstrap itself.
const dht = DHT.load('.dht_state');
dht.listen(/** listening port, can be anything */ 8468);

// create a public/secret key pair to use BEP-44
const keys = ed25519.createKeyPair();

// store mutable value
await dht.put(keys.publicKey, (sign, r) => sign({ v: 'example-mutable'}, keys.secretKey));

// retrieve mutable value
const value = await dht.get({ k: keys.publicKey });
assert value.v == 'example-mutable';