xrpld
Loading...
Searching...
No Matches
xrpl::ConsensusProposal< NodeId, LedgerId, Position > Class Template Reference

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

#include <ConsensusProposal.h>

Collaboration diagram for xrpl::ConsensusProposal< NodeId, LedgerId, Position >:

Public Types

using NodeID = NodeId

Public Member Functions

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

Static Public Attributes

static std::uint32_t const kSeqJoin = 0
static std::uint32_t const kSeqLeave = 0xffffffff

Private Attributes

LedgerId previousLedger_
 Unique identifier of prior ledger this proposal is based on.
Position position_
 Unique identifier of the position this proposal is taking.
NetClock::time_point closeTime_
 The ledger close time this position is taking.
NetClock::time_point time_
std::uint32_t proposeSeq_
 The sequence number of these positions taken by this node.
NodeId nodeID_
 The identifier of the node taking this position.
std::optional< uint256signingHash_
 The signing hash for this proposal.

Detailed Description

template<class NodeId, class LedgerId, class Position>
class xrpl::ConsensusProposal< NodeId, LedgerId, Position >

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

Refer to Consensus for requirements of the template arguments.

Template Parameters
NodeIdType used to uniquely identify nodes/peers
LedgerIdType used to uniquely identify ledgers
PositionType used to represent the position taken on transactions under consideration during this round of consensus

Definition at line 39 of file ConsensusProposal.h.

Member Typedef Documentation

◆ NodeID

template<class NodeId, class LedgerId, class Position>
using xrpl::ConsensusProposal< NodeId, LedgerId, Position >::NodeID = NodeId

Definition at line 42 of file ConsensusProposal.h.

Constructor & Destructor Documentation

◆ ConsensusProposal()

template<class NodeId, class LedgerId, class Position>
xrpl::ConsensusProposal< NodeId, LedgerId, Position >::ConsensusProposal ( LedgerId const & prevLedger,
std::uint32_t seq,
Position const & position,
NetClock::time_point closeTime,
NetClock::time_point now,
NodeId 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 59 of file ConsensusProposal.h.

Member Function Documentation

◆ nodeID()

template<class NodeId, class LedgerId, class Position>
NodeId const & xrpl::ConsensusProposal< NodeId, LedgerId, Position >::nodeID ( ) const

Identifying which peer took this position.

Definition at line 77 of file ConsensusProposal.h.

◆ position()

template<class NodeId, class LedgerId, class Position>
Position const & xrpl::ConsensusProposal< NodeId, LedgerId, Position >::position ( ) const

Get the proposed position.

Definition at line 84 of file ConsensusProposal.h.

◆ prevLedger()

template<class NodeId, class LedgerId, class Position>
LedgerId const & xrpl::ConsensusProposal< NodeId, LedgerId, Position >::prevLedger ( ) const

Get the prior accepted ledger this position is based on.

Definition at line 91 of file ConsensusProposal.h.

◆ proposeSeq()

template<class NodeId, class LedgerId, class Position>
std::uint32_t xrpl::ConsensusProposal< NodeId, LedgerId, Position >::proposeSeq ( ) const

Get the sequence number of this proposal.

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

Returns
the sequence number

Definition at line 104 of file ConsensusProposal.h.

◆ closeTime()

template<class NodeId, class LedgerId, class Position>
NetClock::time_point const & xrpl::ConsensusProposal< NodeId, LedgerId, Position >::closeTime ( ) const

The current position on the consensus close time.

Definition at line 111 of file ConsensusProposal.h.

◆ seenTime()

template<class NodeId, class LedgerId, class Position>
NetClock::time_point const & xrpl::ConsensusProposal< NodeId, LedgerId, Position >::seenTime ( ) const

Get when this position was taken.

Definition at line 118 of file ConsensusProposal.h.

◆ isInitial()

template<class NodeId, class LedgerId, class Position>
bool xrpl::ConsensusProposal< NodeId, LedgerId, Position >::isInitial ( ) const

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

Definition at line 127 of file ConsensusProposal.h.

◆ isBowOut()

template<class NodeId, class LedgerId, class Position>
bool xrpl::ConsensusProposal< NodeId, LedgerId, Position >::isBowOut ( ) const

Get whether this node left the consensus process.

Definition at line 134 of file ConsensusProposal.h.

◆ isStale()

template<class NodeId, class LedgerId, class Position>
bool xrpl::ConsensusProposal< NodeId, LedgerId, Position >::isStale ( NetClock::time_point cutoff) const

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

Definition at line 141 of file ConsensusProposal.h.

◆ changePosition()

template<class NodeId, class LedgerId, class Position>
void xrpl::ConsensusProposal< NodeId, LedgerId, Position >::changePosition ( Position 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 154 of file ConsensusProposal.h.

◆ bowOut()

template<class NodeId, class LedgerId, class Position>
void xrpl::ConsensusProposal< NodeId, LedgerId, Position >::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 174 of file ConsensusProposal.h.

◆ render()

template<class NodeId, class LedgerId, class Position>
std::string xrpl::ConsensusProposal< NodeId, LedgerId, Position >::render ( ) const

Definition at line 182 of file ConsensusProposal.h.

◆ getJson()

template<class NodeId, class LedgerId, class Position>
json::Value xrpl::ConsensusProposal< NodeId, LedgerId, Position >::getJson ( ) const

Get JSON representation for debugging.

Definition at line 194 of file ConsensusProposal.h.

◆ signingHash()

template<class NodeId, class LedgerId, class Position>
uint256 const & xrpl::ConsensusProposal< NodeId, LedgerId, Position >::signingHash ( ) const

The digest for this proposal, used for signing purposes.

Definition at line 214 of file ConsensusProposal.h.

Member Data Documentation

◆ kSeqJoin

template<class NodeId, class LedgerId, class Position>
std::uint32_t const xrpl::ConsensusProposal< NodeId, LedgerId, Position >::kSeqJoin = 0
static

Definition at line 45 of file ConsensusProposal.h.

◆ kSeqLeave

template<class NodeId, class LedgerId, class Position>
std::uint32_t const xrpl::ConsensusProposal< NodeId, LedgerId, Position >::kSeqLeave = 0xffffffff
static

Definition at line 48 of file ConsensusProposal.h.

◆ previousLedger_

template<class NodeId, class LedgerId, class Position>
LedgerId xrpl::ConsensusProposal< NodeId, LedgerId, Position >::previousLedger_
private

Unique identifier of prior ledger this proposal is based on.

Definition at line 231 of file ConsensusProposal.h.

◆ position_

template<class NodeId, class LedgerId, class Position>
Position xrpl::ConsensusProposal< NodeId, LedgerId, Position >::position_
private

Unique identifier of the position this proposal is taking.

Definition at line 234 of file ConsensusProposal.h.

◆ closeTime_

template<class NodeId, class LedgerId, class Position>
NetClock::time_point xrpl::ConsensusProposal< NodeId, LedgerId, Position >::closeTime_
private

The ledger close time this position is taking.

Definition at line 237 of file ConsensusProposal.h.

◆ time_

template<class NodeId, class LedgerId, class Position>
NetClock::time_point xrpl::ConsensusProposal< NodeId, LedgerId, Position >::time_
private

Definition at line 240 of file ConsensusProposal.h.

◆ proposeSeq_

template<class NodeId, class LedgerId, class Position>
std::uint32_t xrpl::ConsensusProposal< NodeId, LedgerId, Position >::proposeSeq_
private

The sequence number of these positions taken by this node.

Definition at line 243 of file ConsensusProposal.h.

◆ nodeID_

template<class NodeId, class LedgerId, class Position>
NodeId xrpl::ConsensusProposal< NodeId, LedgerId, Position >::nodeID_
private

The identifier of the node taking this position.

Definition at line 246 of file ConsensusProposal.h.

◆ signingHash_

template<class NodeId, class LedgerId, class Position>
std::optional<uint256> xrpl::ConsensusProposal< NodeId, LedgerId, Position >::signingHash_
mutableprivate

The signing hash for this proposal.

Definition at line 249 of file ConsensusProposal.h.