rippled
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t > 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 >:
Collaboration graph
[legend]

Public Types

using NodeID = NodeID_t
 

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)
 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...
 

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...
 

Detailed Description

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

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 52 of file ConsensusProposal.h.

Member Typedef Documentation

◆ NodeID

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

Definition at line 55 of file ConsensusProposal.h.

Constructor & Destructor Documentation

◆ ConsensusProposal()

template<class NodeID_t , class LedgerID_t , class Position_t >
ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t >::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 
)

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.

Definition at line 72 of file ConsensusProposal.h.

Member Function Documentation

◆ nodeID()

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

Identifying which peer took this position.

Definition at line 90 of file ConsensusProposal.h.

◆ position()

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

Get the proposed position.

Definition at line 97 of file ConsensusProposal.h.

◆ prevLedger()

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

Get the prior accepted ledger this position is based on.

Definition at line 104 of file ConsensusProposal.h.

◆ proposeSeq()

template<class NodeID_t , class LedgerID_t , class Position_t >
std::uint32_t ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t >::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 117 of file ConsensusProposal.h.

◆ closeTime()

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

The current position on the consensus close time.

Definition at line 124 of file ConsensusProposal.h.

◆ seenTime()

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

Get when this position was taken.

Definition at line 131 of file ConsensusProposal.h.

◆ isInitial()

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

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

Definition at line 140 of file ConsensusProposal.h.

◆ isBowOut()

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

Get whether this node left the consensus process.

Definition at line 147 of file ConsensusProposal.h.

◆ isStale()

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

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

Definition at line 154 of file ConsensusProposal.h.

◆ changePosition()

template<class NodeID_t , class LedgerID_t , class Position_t >
void ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t >::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 167 of file ConsensusProposal.h.

◆ bowOut()

template<class NodeID_t , class LedgerID_t , class Position_t >
void ripple::ConsensusProposal< NodeID_t, LedgerID_t, Position_t >::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 186 of file ConsensusProposal.h.

◆ getJson()

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

Get JSON representation for debugging.

Definition at line 194 of file ConsensusProposal.h.

Member Data Documentation

◆ seqJoin

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

Definition at line 58 of file ConsensusProposal.h.

◆ seqLeave

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

Definition at line 61 of file ConsensusProposal.h.

◆ previousLedger_

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

Unique identifier of prior ledger this proposal is based on.

Definition at line 215 of file ConsensusProposal.h.

◆ position_

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

Unique identifier of the position this proposal is taking.

Definition at line 218 of file ConsensusProposal.h.

◆ closeTime_

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

The ledger close time this position is taking.

Definition at line 221 of file ConsensusProposal.h.

◆ time_

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

Definition at line 224 of file ConsensusProposal.h.

◆ proposeSeq_

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

The sequence number of these positions taken by this node.

Definition at line 227 of file ConsensusProposal.h.

◆ nodeID_

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

The identifier of the node taking this position.

Definition at line 230 of file ConsensusProposal.h.