24#include <condition_variable>
29#include <unordered_map>
35 explicit PingService(std::chrono::milliseconds interval = std::chrono::seconds(10));
50 void handle(
const Peer& peer, ByteView payload);
54 std::chrono::milliseconds interval_;
57 std::atomic<bool> running_{
false};
58 std::mutex wait_mutex_;
59 std::condition_variable wake_;
61 mutable std::mutex mutex_;
62 std::unordered_map<PeerId, std::chrono::milliseconds, PeerId::Hash> rtt_;
void attach(NodeContext &ctx) override
std::optional< std::chrono::milliseconds > last_rtt(const PeerId &id) const
Most recent measured round-trip time to a peer, if one has been seen.
PingService(std::chrono::milliseconds interval=std::chrono::seconds(10))
size_t alive_peer_count() const
Number of peers we have received at least one pong from.
A pluggable network subsystem.
A lightweight handle to a connected peer.
Self-certifying peer identity.
The narrow contract a subsystem needs from the node — and nothing more.