xrpld
Loading...
Searching...
No Matches
xrpl::DisputedTx< Tx, NodeId > Class Template Reference

A transaction discovered to be in dispute during consensus. More...

#include <DisputedTx.h>

Collaboration diagram for xrpl::DisputedTx< Tx, NodeId >:

Public Member Functions

 DisputedTx (Tx tx, bool ourVote, std::size_t numPeers, beast::Journal j)
 Constructor.
TxID_t const & id () const
 The unique id/hash of the disputed transaction.
bool getOurVote () const
 Our vote on whether the transaction should be included.
bool stalled (ConsensusParms const &p, bool proposing, int peersUnchanged, beast::Journal j, std::unique_ptr< std::stringstream > const &clog) const
Tx const & tx () const
 The disputed transaction.
void setOurVote (bool o)
 Change our vote.
bool setVote (NodeId const &peer, bool votesYes)
 Change a peer's vote.
void unVote (NodeId const &peer)
 Remove a peer's vote.
bool updateVote (int percentTime, bool proposing, ConsensusParms const &p)
 Update our vote given progression of consensus.
json::Value getJson () const
 JSON representation of dispute, used for debugging.

Private Types

using TxID_t = Tx::ID
using Map_t = boost::container::flat_map<NodeId, bool>

Private Attributes

int yays_ {0}
int nays_ {0}
bool ourVote_
Tx tx_
Map_t votes_
std::size_t currentVoteCounter_ = 0
 The number of rounds we've gone without changing our vote.
ConsensusParms::AvalancheState avalancheState_ = ConsensusParms::AvalancheState::Init
 Which minimum acceptance percentage phase we are currently in.
std::size_t avalancheCounter_ = 0
 How long we have been in the current acceptance phase.
beast::Journal const j_

Detailed Description

template<class Tx, class NodeId>
class xrpl::DisputedTx< Tx, NodeId >

A transaction discovered to be in dispute during consensus.

During consensus, a DisputedTx is created when a transaction is discovered to be disputed. The object persists only as long as the dispute.

Undisputed transactions have no corresponding DisputedTx object.

Refer to Consensus for details on the template type requirements.

Template Parameters
TxThe type for a transaction
NodeIdThe type for a node identifier

Definition at line 30 of file DisputedTx.h.

Member Typedef Documentation

◆ TxID_t

template<class Tx, class NodeId>
using xrpl::DisputedTx< Tx, NodeId >::TxID_t = Tx::ID
private

Definition at line 32 of file DisputedTx.h.

◆ Map_t

template<class Tx, class NodeId>
using xrpl::DisputedTx< Tx, NodeId >::Map_t = boost::container::flat_map<NodeId, bool>
private

Definition at line 33 of file DisputedTx.h.

Constructor & Destructor Documentation

◆ DisputedTx()

template<class Tx, class NodeId>
xrpl::DisputedTx< Tx, NodeId >::DisputedTx ( Tx tx,
bool ourVote,
std::size_t numPeers,
beast::Journal j )

Constructor.

Parameters
txThe transaction under dispute
ourVoteOur vote on whether tx should be included
numPeersAnticipated number of peer votes
jJournal for debugging

Definition at line 43 of file DisputedTx.h.

Member Function Documentation

◆ id()

template<class Tx, class NodeId>
TxID_t const & xrpl::DisputedTx< Tx, NodeId >::id ( ) const
nodiscard

The unique id/hash of the disputed transaction.

Definition at line 51 of file DisputedTx.h.

◆ getOurVote()

template<class Tx, class NodeId>
bool xrpl::DisputedTx< Tx, NodeId >::getOurVote ( ) const
nodiscard

Our vote on whether the transaction should be included.

Definition at line 58 of file DisputedTx.h.

◆ stalled()

template<class Tx, class NodeId>
bool xrpl::DisputedTx< Tx, NodeId >::stalled ( ConsensusParms const & p,
bool proposing,
int peersUnchanged,
beast::Journal j,
std::unique_ptr< std::stringstream > const & clog ) const
nodiscard

Are we and our peers "stalled" where we probably won't change our vote?

Definition at line 66 of file DisputedTx.h.

◆ tx()

template<class Tx, class NodeId>
Tx const & xrpl::DisputedTx< Tx, NodeId >::tx ( ) const
nodiscard

The disputed transaction.

Definition at line 131 of file DisputedTx.h.

◆ setOurVote()

template<class Tx, class NodeId>
void xrpl::DisputedTx< Tx, NodeId >::setOurVote ( bool o)

Change our vote.

Definition at line 138 of file DisputedTx.h.

◆ setVote()

template<class Tx, class NodeId>
bool xrpl::DisputedTx< Tx, NodeId >::setVote ( NodeId const & peer,
bool votesYes )
nodiscard

Change a peer's vote.

Parameters
peerIdentifier of peer.
votesYesWhether peer votes to include the disputed transaction.
Returns
bool Whether the peer changed its vote. (A new vote counts as a change.)

Definition at line 197 of file DisputedTx.h.

◆ unVote()

template<class Tx, class NodeId>
void xrpl::DisputedTx< Tx, NodeId >::unVote ( NodeId const & peer)

Remove a peer's vote.

Parameters
peerIdentifier of peer.

Definition at line 240 of file DisputedTx.h.

◆ updateVote()

template<class Tx, class NodeId>
bool xrpl::DisputedTx< Tx, NodeId >::updateVote ( int percentTime,
bool proposing,
ConsensusParms const & p )

Update our vote given progression of consensus.

Updates our vote on this disputed transaction based on our peers' votes and how far along consensus has proceeded.

Parameters
percentTimePercentage progress through consensus, e.g. 50% through or 90%.
proposingWhether we are proposing to our peers in this round.
pConsensus parameters controlling thresholds for voting
Returns
Whether our vote changed

Definition at line 261 of file DisputedTx.h.

◆ getJson()

template<class Tx, class NodeId>
json::Value xrpl::DisputedTx< Tx, NodeId >::getJson ( ) const
nodiscard

JSON representation of dispute, used for debugging.

Definition at line 319 of file DisputedTx.h.

Member Data Documentation

◆ yays_

template<class Tx, class NodeId>
int xrpl::DisputedTx< Tx, NodeId >::yays_ {0}
private

Definition at line 180 of file DisputedTx.h.

◆ nays_

template<class Tx, class NodeId>
int xrpl::DisputedTx< Tx, NodeId >::nays_ {0}
private

Definition at line 181 of file DisputedTx.h.

◆ ourVote_

template<class Tx, class NodeId>
bool xrpl::DisputedTx< Tx, NodeId >::ourVote_
private

Definition at line 182 of file DisputedTx.h.

◆ tx_

template<class Tx, class NodeId>
Tx xrpl::DisputedTx< Tx, NodeId >::tx_
private

Definition at line 183 of file DisputedTx.h.

◆ votes_

template<class Tx, class NodeId>
Map_t xrpl::DisputedTx< Tx, NodeId >::votes_
private

Definition at line 184 of file DisputedTx.h.

◆ currentVoteCounter_

template<class Tx, class NodeId>
std::size_t xrpl::DisputedTx< Tx, NodeId >::currentVoteCounter_ = 0
private

The number of rounds we've gone without changing our vote.

Definition at line 186 of file DisputedTx.h.

◆ avalancheState_

template<class Tx, class NodeId>
ConsensusParms::AvalancheState xrpl::DisputedTx< Tx, NodeId >::avalancheState_ = ConsensusParms::AvalancheState::Init
private

Which minimum acceptance percentage phase we are currently in.

Definition at line 188 of file DisputedTx.h.

◆ avalancheCounter_

template<class Tx, class NodeId>
std::size_t xrpl::DisputedTx< Tx, NodeId >::avalancheCounter_ = 0
private

How long we have been in the current acceptance phase.

Definition at line 190 of file DisputedTx.h.

◆ j_

template<class Tx, class NodeId>
beast::Journal const xrpl::DisputedTx< Tx, NodeId >::j_
private

Definition at line 191 of file DisputedTx.h.