我正在寻找C/C++语言的Kademlia分布式哈希表(DHT)的开源实现。它必须轻量级且跨平台(Windows/Linux/Mac)。
它必须能够向DHT发布信息并检索信息。
它必须能够向DHT发布信息并检索信息。
OpenDHT 是一个基于 C++11 的轻量级 Kademlia DHT。它的 API 非常简单:
dht::DhtRunner node;
// Launch a dht node on a new thread, using a
// generated RSA key pair, and listen on port 4222.
node.run(4222, dht::crypto::generateIdentity(), true);
// Join the network through any running node,
// here using a known bootstrap node.
node.bootstrap("bootstrap.jami.net", "4222");
// put some data on the dht
std::vector<uint8_t> some_data(5, 10);
node.put("unique_key", some_data);
它支持在OS X、Linux和Windows上使用LLVM或GCC进行编译。
LibTorrent的Kademlia DHT是用C++编写的,并且有很好的文档。
以下是具有不可变和可变get/put操作的示例代码:https://github.com/arvidn/libtorrent/blob/master/tools/dht_put.cpp