rippled
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq > Class Template Reference

Represents a proposed position taken during a round of consensus. More...

Collaboration diagram for ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >:
Collaboration graph
[legend]

Public Types

using NodeID = NodeID_t
 
using clock_type = beast::abstract_clock< std::chrono::steady_clock >
 Clock type for measuring time within the consensus code. More...
 

Public Member Functions

 ConsensusProposal (LedgerID_t const &prevLedger, std::uint32_t seq, Position_t const &position, NetClock::time_point closeTime, NetClock::time_point now, NodeID_t const &nodeID, std::optional< Seq > const &ledgerSeq, clock_type const &clock)
 Constructor. More...
 
NodeID_t const & nodeID () const
 Identifying which peer took this position. More...
 
Position_t const & position () const
 Get the proposed position. More...
 
LedgerID_t const & prevLedger () const
 Get the prior accepted ledger this position is based on. More...
 
std::uint32_t proposeSeq () const
 Get the sequence number of this proposal. More...
 
NetClock::time_point const & closeTime () const
 The current position on the consensus close time. More...
 
NetClock::time_point const & seenTime () const
 Get when this position was taken. More...
 
bool isInitial () const
 Whether this is the first position taken during the current consensus round. More...
 
bool isBowOut () const
 Get whether this node left the consensus process. More...
 
bool isStale (NetClock::time_point cutoff) const
 Get whether this position is stale relative to the provided cutoff. More...
 
void changePosition (Position_t const &newPosition, NetClock::time_point newCloseTime, NetClock::time_point now)
 Update the position during the consensus process. More...
 
void bowOut (NetClock::time_point now)
 Leave consensus. More...
 
Json::Value getJson () const
 Get JSON representation for debugging. More...
 
uint256 const & signingHash () const
 The digest for this proposal, used for signing purposes. More...
 
std::optional< Seq > const & ledgerSeq () const
 
ConsensusTimerarrivalTime () const
 

Static Public Attributes

static const std::uint32_t seqJoin = 0
 
static const std::uint32_t seqLeave = 0xffffffff
 

Private Attributes

LedgerID_t previousLedger_
 Unique identifier of prior ledger this proposal is based on. More...
 
Position_t position_
 Unique identifier of the position this proposal is taking. More...
 
NetClock::time_point closeTime_
 The ledger close time this position is taking. More...
 
NetClock::time_point time_
 
std::uint32_t proposeSeq_
 The sequence number of these positions taken by this node. More...
 
NodeID_t nodeID_
 The identifier of the node taking this position. More...
 
std::optional< Seq > ledgerSeq_
 
std::optional< uint256signingHash_
 The signing hash for this proposal. More...
 
ConsensusTimer arrivalTime_
 

Detailed Description

template<class NodeID_t, class LedgerID_t, class Position_t, class Seq>
class ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >

Represents a proposed position taken during a round of consensus.

During consensus, peers seek agreement on a set of transactions to apply to the prior ledger to generate the next ledger. Each peer takes a position on whether to include or exclude potential transactions. The position on the set of transactions is proposed to its peers as an instance of the ConsensusProposal class.

An instance of ConsensusProposal can be either our own proposal or one of our peer's.

As consensus proceeds, peers may change their position on the transaction, or choose to abstain. Each successive proposal includes a strictly monotonically increasing number (or, if a peer is choosing to abstain, the special value seqLeave).

Refer to Consensus for requirements of the template arguments.

Template Parameters
NodeID_tType used to uniquely identify nodes/peers
LedgerID_tType used to uniquely identify ledgers
Position_tType used to represent the position taken on transactions under consideration during this round of consensus

Definition at line 59 of file ConsensusProposal.h.

Member Typedef Documentation

◆ NodeID

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
using ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::NodeID = NodeID_t

Definition at line 62 of file ConsensusProposal.h.

◆ clock_type

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
using ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::clock_type = beast::abstract_clock<std::chrono::steady_clock>

Clock type for measuring time within the consensus code.

Definition at line 65 of file ConsensusProposal.h.

Constructor & Destructor Documentation

◆ ConsensusProposal()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::ConsensusProposal ( LedgerID_t const &  prevLedger,
std::uint32_t  seq,
Position_t const &  position,
NetClock::time_point  closeTime,
NetClock::time_point  now,
NodeID_t const &  nodeID,
std::optional< Seq > const &  ledgerSeq,
clock_type const &  clock 
)

Constructor.

Parameters
prevLedgerThe previous ledger this proposal is building on.
seqThe sequence number of this proposal.
positionThe position taken on transactions in this round.
closeTimePosition of when this ledger closed.
nowTime when the proposal was taken.
nodeIDID of node/peer taking this position.
ledgerSeqLedger sequence of proposal.
clockClock that works with real and test time.

Definition at line 84 of file ConsensusProposal.h.

Member Function Documentation

◆ nodeID()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
NodeID_t const& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::nodeID ( ) const

Identifying which peer took this position.

Definition at line 108 of file ConsensusProposal.h.

◆ position()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
Position_t const& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::position ( ) const

Get the proposed position.

Definition at line 115 of file ConsensusProposal.h.

◆ prevLedger()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
LedgerID_t const& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::prevLedger ( ) const

Get the prior accepted ledger this position is based on.

Definition at line 122 of file ConsensusProposal.h.

◆ proposeSeq()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
std::uint32_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::proposeSeq ( ) const

Get the sequence number of this proposal.

Starting with an initial sequence number of seqJoin, successive proposals from a peer will increase the sequence number.

Returns
the sequence number

Definition at line 135 of file ConsensusProposal.h.

◆ closeTime()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
NetClock::time_point const& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::closeTime ( ) const

The current position on the consensus close time.

Definition at line 142 of file ConsensusProposal.h.

◆ seenTime()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
NetClock::time_point const& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::seenTime ( ) const

Get when this position was taken.

Definition at line 149 of file ConsensusProposal.h.

◆ isInitial()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
bool ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::isInitial ( ) const

Whether this is the first position taken during the current consensus round.

Definition at line 158 of file ConsensusProposal.h.

◆ isBowOut()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
bool ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::isBowOut ( ) const

Get whether this node left the consensus process.

Definition at line 165 of file ConsensusProposal.h.

◆ isStale()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
bool ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::isStale ( NetClock::time_point  cutoff) const

Get whether this position is stale relative to the provided cutoff.

Definition at line 172 of file ConsensusProposal.h.

◆ changePosition()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
void ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::changePosition ( Position_t const &  newPosition,
NetClock::time_point  newCloseTime,
NetClock::time_point  now 
)

Update the position during the consensus process.

This will increment the proposal's sequence number if it has not already bowed out.

Parameters
newPositionThe new position taken.
newCloseTimeThe new close time.
nowthe time The new position was taken

Definition at line 185 of file ConsensusProposal.h.

◆ bowOut()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
void ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::bowOut ( NetClock::time_point  now)

Leave consensus.

Update position to indicate the node left consensus.

Parameters
nowTime when this node left consensus.

Definition at line 205 of file ConsensusProposal.h.

◆ getJson()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
Json::Value ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::getJson ( ) const

Get JSON representation for debugging.

Definition at line 214 of file ConsensusProposal.h.

◆ signingHash()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
uint256 const& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::signingHash ( ) const

The digest for this proposal, used for signing purposes.

Definition at line 235 of file ConsensusProposal.h.

◆ ledgerSeq()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
std::optional<Seq> const& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::ledgerSeq ( ) const

Definition at line 251 of file ConsensusProposal.h.

◆ arrivalTime()

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
ConsensusTimer& ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::arrivalTime ( ) const

Definition at line 257 of file ConsensusProposal.h.

Member Data Documentation

◆ seqJoin

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
const std::uint32_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::seqJoin = 0
static

Definition at line 68 of file ConsensusProposal.h.

◆ seqLeave

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
const std::uint32_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::seqLeave = 0xffffffff
static

Definition at line 71 of file ConsensusProposal.h.

◆ previousLedger_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
LedgerID_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::previousLedger_
private

Unique identifier of prior ledger this proposal is based on.

Definition at line 264 of file ConsensusProposal.h.

◆ position_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
Position_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::position_
private

Unique identifier of the position this proposal is taking.

Definition at line 267 of file ConsensusProposal.h.

◆ closeTime_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
NetClock::time_point ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::closeTime_
private

The ledger close time this position is taking.

Definition at line 270 of file ConsensusProposal.h.

◆ time_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
NetClock::time_point ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::time_
private

Definition at line 273 of file ConsensusProposal.h.

◆ proposeSeq_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
std::uint32_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::proposeSeq_
private

The sequence number of these positions taken by this node.

Definition at line 276 of file ConsensusProposal.h.

◆ nodeID_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
NodeID_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::nodeID_
private

The identifier of the node taking this position.

Definition at line 279 of file ConsensusProposal.h.

◆ ledgerSeq_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
std::optional<Seq> ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::ledgerSeq_
private

Definition at line 281 of file ConsensusProposal.h.

◆ signingHash_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
std::optional<uint256> ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::signingHash_
mutableprivate

The signing hash for this proposal.

Definition at line 284 of file ConsensusProposal.h.

◆ arrivalTime_

template<class NodeID_t , class LedgerID_t , class Position_t , class Seq >
ConsensusTimer ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t, Seq >::arrivalTime_
mutableprivate

Definition at line 286 of file ConsensusProposal.h.