API

KNode

The KNode represents a Kademlia node and handles all communication and storage.
This should be the only thing you need to interact with the Kademlia overlay
network.

KNode(configuration)

A KNode is created by passing it an object having address and port
properties. The node will bind to port and start running.

var node = new dht.KNode({ address: '10.100.98.60', port: 12345 });

connect(address, port[, callback])

Used to introduce this Kademlia node to the overlay network. If you know the
address and port of an existing Kademlia peer, you may connect to it so that
this node can become part of the network. If callback is passed it is called
with the result of the join. connectsucceeds (err is null) when the
entire Kademlia join
sequence
is finished.

get(key, callback)

Gets the value associated with key from the Kademlia network. callback is
a function with arguments (err, value). If the value is found, err is
null, otherwise err will be an object containing information about what
went wrong and value will be null.

set(key, value[, callback])

Store the key, value pair in the Kademlia network. set() is not
guaranteed to succeed. callback can be used to check the result of the store.
It is function (err). If the store succeeded, err is null, otherwise
err describes what went wrong.