rippled
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
ripple::DisputedTx< Tx_t, NodeID_t > Class Template Reference

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

#include <DisputedTx.h>

Collaboration diagram for ripple::DisputedTx< Tx_t, NodeID_t >:
Collaboration graph
[legend]

Public Member Functions

 DisputedTx (Tx_t const &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
 Are we and our peers "stalled" where we probably won't change our vote?
 
Tx_t const & tx () const
 The disputed transaction.
 
void setOurVote (bool o)
 Change our vote.
 
bool setVote (NodeID_t const &peer, bool votesYes)
 Change a peer's vote.
 
void unVote (NodeID_t 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 = typename Tx_t::ID
 
using Map_t = boost::container::flat_map< NodeID_t, bool >
 

Private Attributes

int yays_
 
int nays_
 
bool ourVote_
 
Tx_t tx_
 
Map_t votes_
 
std::size_t currentVoteCounter_ = 0
 The number of rounds we've gone without changing our vote.
 
ConsensusParms::AvalancheState avalancheState_ = ConsensusParms::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_t, class NodeID_t>
class ripple::DisputedTx< Tx_t, NodeID_t >

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
Tx_tThe type for a transaction
NodeID_tThe type for a node identifier

Definition at line 48 of file DisputedTx.h.

Member Typedef Documentation

◆ TxID_t

template<class Tx_t , class NodeID_t >
using ripple::DisputedTx< Tx_t, NodeID_t >::TxID_t = typename Tx_t::ID
private

Definition at line 50 of file DisputedTx.h.

◆ Map_t

template<class Tx_t , class NodeID_t >
using ripple::DisputedTx< Tx_t, NodeID_t >::Map_t = boost::container::flat_map<NodeID_t, bool>
private

Definition at line 51 of file DisputedTx.h.

Constructor & Destructor Documentation

◆ DisputedTx()

template<class Tx_t , class NodeID_t >
ripple::DisputedTx< Tx_t, NodeID_t >::DisputedTx ( Tx_t const &  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 61 of file DisputedTx.h.

Member Function Documentation

◆ ID()

template<class Tx_t , class NodeID_t >
TxID_t const & ripple::DisputedTx< Tx_t, NodeID_t >::ID ( ) const

The unique id/hash of the disputed transaction.

Definition at line 73 of file DisputedTx.h.

◆ getOurVote()

template<class Tx_t , class NodeID_t >
bool ripple::DisputedTx< Tx_t, NodeID_t >::getOurVote ( ) const

Our vote on whether the transaction should be included.

Definition at line 80 of file DisputedTx.h.

◆ stalled()

template<class Tx_t , class NodeID_t >
bool ripple::DisputedTx< Tx_t, NodeID_t >::stalled ( ConsensusParms const &  p,
bool  proposing,
int  peersUnchanged,
beast::Journal  j,
std::unique_ptr< std::stringstream > const &  clog 
) const

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

Definition at line 88 of file DisputedTx.h.

◆ tx()

template<class Tx_t , class NodeID_t >
Tx_t const & ripple::DisputedTx< Tx_t, NodeID_t >::tx ( ) const

The disputed transaction.

Definition at line 153 of file DisputedTx.h.

◆ setOurVote()

template<class Tx_t , class NodeID_t >
void ripple::DisputedTx< Tx_t, NodeID_t >::setOurVote ( bool  o)

Change our vote.

Definition at line 160 of file DisputedTx.h.

◆ setVote()

template<class Tx_t , class NodeID_t >
bool ripple::DisputedTx< Tx_t, NodeID_t >::setVote ( NodeID_t const &  peer,
bool  votesYes 
)

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 219 of file DisputedTx.h.

◆ unVote()

template<class Tx_t , class NodeID_t >
void ripple::DisputedTx< Tx_t, NodeID_t >::unVote ( NodeID_t const &  peer)

Remove a peer's vote.

Parameters
peerIdentifier of peer.

Definition at line 262 of file DisputedTx.h.

◆ updateVote()

template<class Tx_t , class NodeID_t >
bool ripple::DisputedTx< Tx_t, NodeID_t >::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 279 of file DisputedTx.h.

◆ getJson()

template<class Tx_t , class NodeID_t >
Json::Value ripple::DisputedTx< Tx_t, NodeID_t >::getJson ( ) const

JSON representation of dispute, used for debugging.

Definition at line 342 of file DisputedTx.h.

Member Data Documentation

◆ yays_

template<class Tx_t , class NodeID_t >
int ripple::DisputedTx< Tx_t, NodeID_t >::yays_
private

Definition at line 202 of file DisputedTx.h.

◆ nays_

template<class Tx_t , class NodeID_t >
int ripple::DisputedTx< Tx_t, NodeID_t >::nays_
private

Definition at line 203 of file DisputedTx.h.

◆ ourVote_

template<class Tx_t , class NodeID_t >
bool ripple::DisputedTx< Tx_t, NodeID_t >::ourVote_
private

Definition at line 204 of file DisputedTx.h.

◆ tx_

template<class Tx_t , class NodeID_t >
Tx_t ripple::DisputedTx< Tx_t, NodeID_t >::tx_
private

Definition at line 205 of file DisputedTx.h.

◆ votes_

template<class Tx_t , class NodeID_t >
Map_t ripple::DisputedTx< Tx_t, NodeID_t >::votes_
private

Definition at line 206 of file DisputedTx.h.

◆ currentVoteCounter_

template<class Tx_t , class NodeID_t >
std::size_t ripple::DisputedTx< Tx_t, NodeID_t >::currentVoteCounter_ = 0
private

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

Definition at line 208 of file DisputedTx.h.

◆ avalancheState_

template<class Tx_t , class NodeID_t >
ConsensusParms::AvalancheState ripple::DisputedTx< Tx_t, NodeID_t >::avalancheState_ = ConsensusParms::init
private

Which minimum acceptance percentage phase we are currently in.

Definition at line 210 of file DisputedTx.h.

◆ avalancheCounter_

template<class Tx_t , class NodeID_t >
std::size_t ripple::DisputedTx< Tx_t, NodeID_t >::avalancheCounter_ = 0
private

How long we have been in the current acceptance phase.

Definition at line 212 of file DisputedTx.h.

◆ j_

template<class Tx_t , class NodeID_t >
beast::Journal const ripple::DisputedTx< Tx_t, NodeID_t >::j_
private

Definition at line 213 of file DisputedTx.h.