rippled
Loading...
Searching...
No Matches
Cluster.h
1#pragma once
2
3#include <xrpld/overlay/ClusterNode.h>
4
5#include <xrpl/basics/BasicConfig.h>
6#include <xrpl/basics/chrono.h>
7#include <xrpl/beast/utility/Journal.h>
8#include <xrpl/protocol/PublicKey.h>
9
10#include <functional>
11#include <mutex>
12#include <set>
13
14namespace xrpl {
15
17{
18private:
20 {
21 explicit Comparator() = default;
22
24
25 bool
26 operator()(ClusterNode const& lhs, ClusterNode const& rhs) const
27 {
28 return lhs.identity() < rhs.identity();
29 }
30
31 bool
32 operator()(ClusterNode const& lhs, PublicKey const& rhs) const
33 {
34 return lhs.identity() < rhs;
35 }
36
37 bool
38 operator()(PublicKey const& lhs, ClusterNode const& rhs) const
39 {
40 return lhs < rhs.identity();
41 }
42 };
43
47
48public:
50
57 member(PublicKey const& node) const;
58
61 size() const;
62
68 bool
69 update(
70 PublicKey const& identity,
71 std::string name,
72 std::uint32_t loadFee = 0,
74
79 void
80 for_each(std::function<void(ClusterNode const&)> func) const;
81
92 bool
93 load(Section const& nodes);
94};
95
96} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
PublicKey const & identity() const
Definition ClusterNode.h:44
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::mutex mutex_
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:60
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
Definition Cluster.cpp:19
beast::Journal j_
Definition Cluster.h:46
std::set< ClusterNode, Comparator > nodes_
Definition Cluster.h:44
bool load(Section const &nodes)
Load the list of cluster nodes.
Definition Cluster.cpp:68
std::size_t size() const
The number of nodes in the cluster list.
Definition Cluster.cpp:30
A public key.
Definition PublicKey.h:42
Holds a collection of configuration values.
Definition BasicConfig.h:24
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:26
bool operator()(ClusterNode const &lhs, PublicKey const &rhs) const
Definition Cluster.h:32
bool operator()(PublicKey const &lhs, ClusterNode const &rhs) const
Definition Cluster.h:38