Skip to content

Commit

Permalink
[FOLD] Review feedback from @thejohnfreeman and @scottschurr:
Browse files Browse the repository at this point in the history
* Use std::if_any to simplify the JobQueue::isOverloaded loop.
* Improved and clarified a couple of different comments in the TxQ.
  • Loading branch information
ximinez committed Dec 11, 2021
1 parent a596e76 commit 5923a8d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
15 changes: 13 additions & 2 deletions src/ripple/app/misc/TxQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,25 @@ class TxQ
}
};

/// Used for sorting @ref MaybeTx by `feeLevel` descending, then by
/// transaction ID ascending
/// Used for sorting @ref MaybeTx
class OrderCandidates
{
public:
/// Default constructor
explicit OrderCandidates() = default;

/** Sort @ref MaybeTx by `feeLevel` descending, then by
* transaction ID ascending
*
* The transaction queue is ordered such that transactions
* paying a higher fee are in front of transactions paying
* a lower fee, giving them an opportunity to be processed into
* the open ledger first. Within transactions paying the same
* fee, order by the arbitrary but consistent transaction ID.
* This allows validators to build similar queues in the same
* order, and thus have more similar initial proposals.
*
*/
bool
operator()(const MaybeTx& lhs, const MaybeTx& rhs) const
{
Expand Down
6 changes: 6 additions & 0 deletions src/ripple/app/misc/impl/TxQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,12 @@ TxQ::apply(
}
if (lastRIter == byFee_.rend())
{
// The only way this condition can happen is if the entire
// queue is filled with transactions from this account. This
// is impossible with default settings - minimum queue size
// is 2000, and an account can only have 10 transactions
// queued. However, it can occur if settings are changed,
// and there is unit test coverage.
JLOG(j_.info())
<< "Queue is full, and transaction " << transactionID
<< " would kick a transaction from the same account ("
Expand Down
10 changes: 3 additions & 7 deletions src/ripple/core/impl/JobQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,9 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed)
bool
JobQueue::isOverloaded()
{
for (auto& x : m_jobData)
{
if (x.second.load().isOver())
return true;
}

return false;
return std::any_of(m_jobData.begin(), m_jobData.end(), [](auto& entry) {
return entry.second.load().isOver();
});
}

Json::Value
Expand Down

0 comments on commit 5923a8d

Please sign in to comment.