rippled
Public Member Functions | Private Attributes | List of all members
ripple::NetworkValidatedLedgers Class Reference

This datastructure is used to keep track of the sequence of the most recent ledger validated by the network. More...

Collaboration diagram for ripple::NetworkValidatedLedgers:
Collaboration graph
[legend]

Public Member Functions

void push (uint32_t idx)
 Notify the datastructure that idx has been validated by the network. More...
 
std::optional< uint32_t > getMostRecent () const
 Get most recently validated sequence. More...
 
std::optional< uint32_t > tryGetMostRecent () const
 Get most recently validated sequence. More...
 
bool waitUntilValidatedByNetwork (uint32_t sequence)
 Waits for the sequence to be validated by the network. More...
 
void stop ()
 Puts the datastructure in the stopped state Future calls to this datastructure will not block This operation cannot be reversed. More...
 

Private Attributes

std::optional< uint32_t > max_
 
std::mutex m_
 
std::condition_variable cv_
 
bool stopping_ = false
 

Detailed Description

This datastructure is used to keep track of the sequence of the most recent ledger validated by the network.

There are two methods that will wait until certain conditions are met. This datastructure is able to be "stopped". When the datastructure is stopped, any threads currently waiting are unblocked. Any later calls to methods of this datastructure will not wait. Once the datastructure is stopped, the datastructure remains stopped for the rest of its lifetime.

Definition at line 39 of file ETLHelpers.h.

Member Function Documentation

◆ push()

void ripple::NetworkValidatedLedgers::push ( uint32_t  idx)

Notify the datastructure that idx has been validated by the network.

Parameters
idxsequence validated by network

Definition at line 54 of file ETLHelpers.h.

◆ getMostRecent()

std::optional<uint32_t> ripple::NetworkValidatedLedgers::getMostRecent ( ) const

Get most recently validated sequence.

If no ledgers are known to have been validated, this function waits until the next ledger is validated

Returns
sequence of most recently validated ledger. empty optional if the datastructure has been stopped

Definition at line 67 of file ETLHelpers.h.

◆ tryGetMostRecent()

std::optional<uint32_t> ripple::NetworkValidatedLedgers::tryGetMostRecent ( ) const

Get most recently validated sequence.

Returns
sequence of most recently validated ledger, or empty optional if no ledgers are known to have been validated.

Definition at line 78 of file ETLHelpers.h.

◆ waitUntilValidatedByNetwork()

bool ripple::NetworkValidatedLedgers::waitUntilValidatedByNetwork ( uint32_t  sequence)

Waits for the sequence to be validated by the network.

Parameters
sequenceto wait for
Returns
true if sequence was validated, false otherwise a return value of false means the datastructure has been stopped

Definition at line 89 of file ETLHelpers.h.

◆ stop()

void ripple::NetworkValidatedLedgers::stop ( )

Puts the datastructure in the stopped state Future calls to this datastructure will not block This operation cannot be reversed.

Definition at line 102 of file ETLHelpers.h.

Member Data Documentation

◆ max_

std::optional<uint32_t> ripple::NetworkValidatedLedgers::max_
private

Definition at line 42 of file ETLHelpers.h.

◆ m_

std::mutex ripple::NetworkValidatedLedgers::m_
mutableprivate

Definition at line 44 of file ETLHelpers.h.

◆ cv_

std::condition_variable ripple::NetworkValidatedLedgers::cv_
mutableprivate

Definition at line 46 of file ETLHelpers.h.

◆ stopping_

bool ripple::NetworkValidatedLedgers::stopping_ = false
private

Definition at line 48 of file ETLHelpers.h.