node中的一個DHT實現:Kademlia
node中的一個Kademlia DHT實現, 可被用作分布式數據存儲。
Install using npm install kademlia
Use:
var dht = require('kademlia')
var node = new dht.KNode({ address: 'IP address', port: portNumber });
node.connect('existing peer ip', port);
node.set('foo', 'bar');
node.get('foo', function(err, data) {
console.log("Retrieved", data, "from DHT");
console.log(data == 'bar');
});
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 });
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!