xrpld
Loading...
Searching...
No Matches
Cluster.h
1#pragma once
2
3#include <xrpld/overlay/ClusterNode.h>
4
5#include <xrpl/basics/chrono.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/config/BasicConfig.h>
8#include <xrpl/protocol/PublicKey.h>
9
10#include <cstddef>
11#include <cstdint>
12#include <functional>
13#include <mutex>
14#include <optional>
15#include <set>
16#include <string>
17#include <type_traits>
18
19namespace xrpl {
20
22{
23private:
25 {
26 explicit Comparator() = default;
27
28 // NOLINTNEXTLINE(readability-identifier-naming) -- std heterogeneous-lookup concept name
30
31 bool
32 operator()(ClusterNode const& lhs, ClusterNode const& rhs) const
33 {
34 return lhs.identity() < rhs.identity();
35 }
36
37 bool
38 operator()(ClusterNode const& lhs, PublicKey const& rhs) const
39 {
40 return lhs.identity() < rhs;
41 }
42
43 bool
44 operator()(PublicKey const& lhs, ClusterNode const& rhs) const
45 {
46 return lhs < rhs.identity();
47 }
48 };
49
53
54public:
56
64 member(PublicKey const& node) const;
65
76 bool
77 isMember(PublicKey const& node) const;
78
83 size() const;
84
91 bool
92 update(
93 PublicKey const& identity,
94 std::string name,
95 std::uint32_t loadFee = 0,
97
103 void
104 forEach(std::function<void(ClusterNode const&)> func) const;
105
117 bool
118 load(Section const& nodes);
119};
120
121} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
PublicKey const & identity() const
Definition ClusterNode.h:45
Cluster(beast::Journal j)
Definition Cluster.cpp:26
bool update(PublicKey const &identity, std::string name, std::uint32_t loadFee=0, NetClock::time_point reportTime=NetClock::time_point{})
Store information about the state of a cluster node.
Definition Cluster.cpp:58
std::mutex mutex_
Definition Cluster.h:51
void forEach(std::function< void(ClusterNode const &)> func) const
Invokes the callback once for every cluster node.
Definition Cluster.cpp:84
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
Definition Cluster.cpp:31
bool isMember(PublicKey const &node) const
Determines whether a node belongs in the cluster.
Definition Cluster.cpp:42
beast::Journal j_
Definition Cluster.h:52
std::set< ClusterNode, Comparator > nodes_
Definition Cluster.h:50
bool load(Section const &nodes)
Load the list of cluster nodes.
Definition Cluster.cpp:92
std::size_t size() const
The number of nodes in the cluster list.
Definition Cluster.cpp:50
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
A public key.
Definition PublicKey.h:53
Holds a collection of configuration values.
Definition BasicConfig.h:28
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool operator()(ClusterNode const &lhs, ClusterNode const &rhs) const
Definition Cluster.h:32
std::true_type is_transparent
Definition Cluster.h:29
bool operator()(ClusterNode const &lhs, PublicKey const &rhs) const
Definition Cluster.h:38
bool operator()(PublicKey const &lhs, ClusterNode const &rhs) const
Definition Cluster.h:44