From eb0d499d0071419cefaeeb81f994e6e2833849c8 Mon Sep 17 00:00:00 2001 From: James Keane Date: Thu, 14 Dec 2023 20:34:47 -0500 Subject: [PATCH] Update README.md --- README.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7160dfb..8ab7e15 100644 --- a/README.md +++ b/README.md @@ -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'; ```