rippled
Classes | Public Member Functions | Private Attributes | List of all members
ripple::Cluster Class Reference
Collaboration diagram for ripple::Cluster:
Collaboration graph
[legend]

Classes

struct  Comparator
 

Public Member Functions

 Cluster (beast::Journal j)
 
std::optional< std::stringmember (PublicKey const &node) const
 Determines whether a node belongs in the cluster. More...
 
std::size_t size () const
 The number of nodes in the cluster list. More...
 
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. More...
 
void for_each (std::function< void(ClusterNode const &)> func) const
 Invokes the callback once for every cluster node. More...
 
bool load (Section const &nodes)
 Load the list of cluster nodes. More...
 

Private Attributes

std::set< ClusterNode, Comparatornodes_
 
std::mutex mutex_
 
beast::Journal j_
 

Detailed Description

Definition at line 38 of file Cluster.h.

Constructor & Destructor Documentation

◆ Cluster()

ripple::Cluster::Cluster ( beast::Journal  j)

Definition at line 34 of file Cluster.cpp.

Member Function Documentation

◆ member()

std::optional< std::string > ripple::Cluster::member ( PublicKey const &  node) const

Determines whether a node belongs in the cluster.

Returns
std::nullopt if the node isn't a member, otherwise, the comment associated with the node (which may be an empty string).

Definition at line 39 of file Cluster.cpp.

◆ size()

std::size_t ripple::Cluster::size ( ) const

The number of nodes in the cluster list.

Definition at line 50 of file Cluster.cpp.

◆ update()

bool ripple::Cluster::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.

Parameters
identityThe node's public identity
nameThe node's name (may be empty)
Returns
true if we updated our information

Definition at line 58 of file Cluster.cpp.

◆ for_each()

void ripple::Cluster::for_each ( std::function< void(ClusterNode const &)>  func) const

Invokes the callback once for every cluster node.

Note
You are not allowed to call update from within the callback.

Definition at line 84 of file Cluster.cpp.

◆ load()

bool ripple::Cluster::load ( Section const &  nodes)

Load the list of cluster nodes.

The section contains entries consisting of a base58 encoded node public key, optionally followed by a comment.

Returns
false if an entry could not be parsed or contained an invalid node public key, true otherwise.

Definition at line 92 of file Cluster.cpp.

Member Data Documentation

◆ nodes_

std::set<ClusterNode, Comparator> ripple::Cluster::nodes_
private

Definition at line 66 of file Cluster.h.

◆ mutex_

std::mutex ripple::Cluster::mutex_
mutableprivate

Definition at line 67 of file Cluster.h.

◆ j_

beast::Journal ripple::Cluster::j_
mutableprivate

Definition at line 68 of file Cluster.h.