Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskeane committed Dec 15, 2023
1 parent 4d8f19d commit eb0d499
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
![Kadem](https://i.imgur.com/5yfwRZM.png)
[![CI](https://github.com/jameskeane/kadem/actions/workflows/ci.yml/badge.svg)](https://github.com/jameskeane/kadem/actions/workflows/ci.yml)

An implementation of the Kademlia DHT.
An implementation of the BiTorrent DHT (Kademlia).

Supports:
- BEP-42 with `sse4_crc32` optional dependency.
- BEP-44 with `ed25519-supercop` optional dependency.

## Usage
`npm install kadem`

```javascript
import DHT from '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();

// 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);
// store mutable value
dht.put(keys.publicKey, (sign, r) => sign({ v: 'example-mutable'}, keys.secretKey));

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

0 comments on commit eb0d499

Please sign in to comment.