KadOH routing table
Kademlia routing table implementation roughly extracted from KadOH.
$ npm install kadoh-routing-table
Basic use
var RoutingTable = ;var rootID = 'e97750256dc9fd98a1f773448af26292d7ef7e02'; // create a routing table wit rootID as root nodevar table = rootID;// will starth the timers for 'refresh'tablestart; // instanciate a new peer with a given address and given IDvar peer = '173.194.40.96' 'd5496cba6d508edb8f007e8e3325b971866b6002'; // add a peer to the routing table: inside they are sorted into KBucketstable; // later, if you see activity of this peer 'touch' it to know// that it's still freshpeer; // to get the number of Kbucketstable; // get 3 closest peers to the given id:// return a PeerArraytable; table; // stop the routing tabletable; // other internal stuff, read the code
Todo
- extract iterative lookup arlgorithm implementations: IterativeFindNode and IterativeFindValue based on eventually
- externalize "crypto" stuff: distance, ..
- rename
PeerArray
intoPeerCollection
and add lodash magic (a la Backbone Collection) - refactor implementaion to be light
- use/learn from https://github.com/tristanls/k-bucket
- other features?