Skip to content

Routing Table

alexstrat edited this page May 19, 2012 · 3 revisions

RoutingTable is the object where a Node stores informations about peers from the DHT. Peers are aggregated by buckets, ordered in a tree given their ID. KadOH can abstract the way this object works internally, but comes up with an implemented version for Kademlia, based on the XOR distance.

Here is how the data structure can be represented for the Kademlia protocol :

This object inherits from EventEmitter and provides a public API.

Interface

Routing Table provides a set of functions to deal with the addition and the consumption of Peers from the table.

# rt.addPeer(peer)

Add a peer to the routing table.

# rt.removePeer(peer)

Remove a peer from the routing table.

# rt.getClosePeers(peer[, limit][, exclude])

Returns the closest peers from a given peer. This function provides a mapping from any peer to a list of peers to perform iterative routing in the DHT. This is the way you want to consume elements from a routing table.

You can provide an integer limit, which is set by default to K, and an array of peers to exclude from the mapping. It can be useful to remove the peer element itself from the result.

Events

As an EventEmitter, the RoutingTable emits events that can be processed by the Node object.

# rt.emit "refresh" (bucket)

The refresh event is emitted whenever a given bucket has not been updated for a given set of time. This is useful to perform refresh operation on a regular basis to bring up to date precise buckets of the routing table.

TODO

We plan to improve the routing table tree to add better routing informations by supporting what is called Split Symbols and Discrete Symbols (see)

Clone this wiki locally