rc-kademlia
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

rc-kademlia 🕸️

Build Status Try rc-kademlia on RunKit install size

This is a DHT for use on a local network. It takes bootstrap peer information or will broadcast on port 1338 asking for local peers. The local peer discovery uses udp Datagrams which can be relied upon to arrive as a whole message. A small binary packet is used to communicate info

Install

npm install rc-kademlia

Development

To build and run 10 nodes type

docker-compose up --build --scale node=10

Example

Overview

API

tk

function tk<T>(size: number, iterable: AsyncIterable<T>): AsyncIterableIterator<T[]>
function tk<T>(size: number, iterable: Iterable<T>): IterableIterator<T[]>

TK means "to come" in editing parlance. This isn't a real function - the api is TK

size can be betweeen 1 and Infinity.

import { batch } from 'rc-kademlia'
import { getPokemon } from 'iterable-pokedex'
 
// batch 10 pokemon while we process them
for await (const pokemons of batch(10, getPokemon())) {
  console.log(pokemons) // 10 pokemon at a time!
}

Contributors wanted!

Writing docs and code is a lot of work! Thank you in advance for helping out.

TODO

Tomorrow I want to get

  • limit local peer discovery to one node
  • find_node request and response flow
  • the recursive find_node search
  • actual good find_node results
  • A better way of visualizing what's going on
  • dht bootstrapping process (does this need a real address book with actual k-buckets? Maybe)

Thing I probably won't do tomorrow

  • peer state and removal
    • responses should count as a pong
  • store and find_value
  • a real k-bucket address book

Things I'll probably have to do but don't want to

  • test with many more peers
  • visualize what's going on with many more peers

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    1

Package Sidebar

Install

npm i rc-kademlia

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

39.1 kB

Total Files

22

Last publish

Collaborators

  • reconbot