20 #ifndef RIPPLE_APP_CONSENSUS_IMPL_DISPUTEDTX_H_INCLUDED
21 #define RIPPLE_APP_CONSENSUS_IMPL_DISPUTEDTX_H_INCLUDED
23 #include <ripple/basics/Log.h>
24 #include <ripple/basics/base_uint.h>
25 #include <ripple/beast/utility/Journal.h>
26 #include <ripple/consensus/ConsensusParms.h>
27 #include <ripple/json/json_writer.h>
28 #include <ripple/protocol/Serializer.h>
29 #include <ripple/protocol/UintTypes.h>
30 #include <boost/container/flat_map.hpp>
49 template <
class Tx_t,
class NodeID_t>
53 using Map_t = boost::container::flat_map<NodeID_t, bool>;
107 setVote(NodeID_t
const& peer,
bool votesYes);
114 unVote(NodeID_t
const& peer);
144 template <
class Tx_t,
class NodeID_t>
148 auto const [it, inserted] = votes_.insert(
std::make_pair(peer, votesYes));
155 JLOG(j_.
debug()) <<
"Peer " << peer <<
" votes YES on " << tx_.id();
160 JLOG(j_.
debug()) <<
"Peer " << peer <<
" votes NO on " << tx_.id();
165 else if (votesYes && !it->second)
167 JLOG(j_.
debug()) <<
"Peer " << peer <<
" now votes YES on " << tx_.id();
173 else if (!votesYes && it->second)
175 JLOG(j_.
debug()) <<
"Peer " << peer <<
" now votes NO on " << tx_.id();
183 template <
class Tx_t,
class NodeID_t>
187 auto it = votes_.find(peer);
189 if (it != votes_.end())
200 template <
class Tx_t,
class NodeID_t>
207 if (ourVote_ && (nays_ == 0))
210 if (!ourVote_ && (yays_ == 0))
219 weight = (yays_ * 100 + (ourVote_ ? 100 : 0)) / (nays_ + yays_ + 1);
236 newPosition = yays_ > nays_;
239 if (newPosition == ourVote_)
241 JLOG(j_.
info()) <<
"No change (" << (ourVote_ ?
"YES" :
"NO")
242 <<
") : weight " << weight <<
", percent "
248 ourVote_ = newPosition;
249 JLOG(j_.
debug()) <<
"We now vote " << (ourVote_ ?
"YES" :
"NO") <<
" on "
255 template <
class Tx_t,
class NodeID_t>
265 ret[
"our_vote"] = ourVote_;
270 for (
auto const& [nodeId, vote] : votes_)
272 ret[
"votes"] = std::move(votesj);
void setOurVote(bool o)
Change our vote.
Json::Value getJson() const
JSON representation of dispute, used for debugging.
@ proposing
We are normal participant in consensus and propose our position.
std::size_t avMID_CONSENSUS_TIME
Percentage of previous round duration before we advance.
std::size_t avLATE_CONSENSUS_PCT
Percentage of nodes that most vote yes after advancing.
Decorator for streaming out compact json.
std::size_t avSTUCK_CONSENSUS_PCT
Percentage of nodes that must vote yes after we are stuck.
void setVote(NodeID_t const &peer, bool votesYes)
Change a peer's vote.
TxID_t const & ID() const
The unique id/hash of the disputed transaction.
Tx_t const & tx() const
The disputed transaction.
void unVote(NodeID_t const &peer)
Remove a peer's vote.
DisputedTx(Tx_t const &tx, bool ourVote, std::size_t numPeers, beast::Journal j)
Constructor.
boost::container::flat_map< NodeID_t, bool > Map_t
@ objectValue
object value (collection of name/value pairs).
bool getOurVote() const
Our vote on whether the transaction should be included.
std::size_t avINIT_CONSENSUS_PCT
Percentage of nodes on our UNL that must vote yes.
A generic endpoint for log messages.
std::size_t avMID_CONSENSUS_PCT
Percentage of nodes that most vote yes after advancing.
bool updateVote(int percentTime, bool proposing, ConsensusParms const &p)
Update our vote given progression of consensus.
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Consensus algorithm parameters.
std::size_t avSTUCK_CONSENSUS_TIME
Percentage of previous round duration before we are stuck.
A transaction discovered to be in dispute during consensus.
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
std::size_t avLATE_CONSENSUS_TIME
Percentage of previous round duration before we advance.