Peer discovery via the Kademlia DHT — a thin adapter, not a rewrite. More...
#include "node/peer_network.h"#include "subsystems/dht_service.h"#include "dht/dht.h"#include <atomic>#include <chrono>#include <condition_variable>#include <cstdint>#include <memory>#include <mutex>#include <string>#include <thread>#include <unordered_set>#include <vector>Go to the source code of this file.
Classes | |
| class | librats::DhtDiscovery |
| struct | librats::DhtDiscovery::Config |
Namespaces | |
| namespace | librats |
Peer discovery via the Kademlia DHT — a thin adapter, not a rewrite.
Wraps the existing, well-tested DhtClient (src/dht.h) as a Subsystem WITHOUT modifying it. On start it brings up DhtClients (their own UDP sockets + threads), then periodically announces our TCP listen port under a discovery hash and searches that hash, dialing any peers it finds through the node. The discovery hash namespaces peers of the same application (same key → same hash).
Dual-stack: IPv4 and IPv6 are separate Kademlia networks (BEP 32), so each runs its own DhtClient. Both announce/search the same hash and feed discovered peers to the same dial path, so a peer reachable over either family is found. Startup is best-effort per family: if one family can't bind (e.g. a host with no usable IPv6) the subsystem still runs on the other.
Everything DHT-specific stays in DhtClient; this class only bridges its callbacks to PeerNetwork::connect().
Definition in file dht_discovery.h.