rippled
Loading...
Searching...
No Matches
Cluster.h
1#ifndef XRPL_OVERLAY_CLUSTER_H_INCLUDED
2#define XRPL_OVERLAY_CLUSTER_H_INCLUDED
3
4#include <xrpld/overlay/ClusterNode.h>
5
6#include <xrpl/basics/BasicConfig.h>
7#include <xrpl/basics/chrono.h>
8#include <xrpl/beast/utility/Journal.h>
9#include <xrpl/protocol/PublicKey.h>
10
11#include <functional>
12#include <mutex>
13#include <set>
14
15namespace ripple {
16
18{
19private:
21 {
22 explicit Comparator() = default;
23
25
26 bool
27 operator()(ClusterNode const& lhs, ClusterNode const& rhs) const
28 {
29 return lhs.identity() < rhs.identity();
30 }
31
32 bool
33 operator()(ClusterNode const& lhs, PublicKey const& rhs) const
34 {
35 return lhs.identity() < rhs;
36 }
37
38 bool
39 operator()(PublicKey const& lhs, ClusterNode const& rhs) const
40 {
41 return lhs < rhs.identity();
42 }
43 };
44
48
49public:
51
58 member(PublicKey const& node) const;
59
62 size() const;
63
69 bool
70 update(
71 PublicKey const& identity,
72 std::string name,
73 std::uint32_t loadFee = 0,
75
80 void
81 for_each(std::function<void(ClusterNode const&)> func) const;
82
93 bool
94 load(Section const& nodes);
95};
96
97} // namespace ripple
98
99#endif
A generic endpoint for log messages.
Definition Journal.h:41
PublicKey const & identity() const
Definition ClusterNode.h:45
std::set< ClusterNode, Comparator > nodes_
Definition Cluster.h:45
void for_each(std::function< void(ClusterNode const &)> func) const
Invokes the callback once for every cluster node.
Definition Cluster.cpp:64
std::size_t size() const
The number of nodes in the cluster list.
Definition Cluster.cpp:30
bool load(Section const &nodes)
Load the list of cluster nodes.
Definition Cluster.cpp:72
beast::Journal j_
Definition Cluster.h:47
std::mutex mutex_
Definition Cluster.h:46
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:38
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
Definition Cluster.cpp:19
A public key.
Definition PublicKey.h:43
Holds a collection of configuration values.
Definition BasicConfig.h:26
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
bool operator()(ClusterNode const &lhs, PublicKey const &rhs) const
Definition Cluster.h:33
bool operator()(PublicKey const &lhs, ClusterNode const &rhs) const
Definition Cluster.h:39
bool operator()(ClusterNode const &lhs, ClusterNode const &rhs) const
Definition Cluster.h:27