Make transaction queue order deterministic:

* Sort by fee level (which is the current behavior) then by transaction
  ID (hash).
* Edge case when the account at the end of the queue submits a higher
  paying transaction to walk backwards and compare against the cheapest
  transaction from a different account.
* Use std::if_any to simplify the JobQueue::isOverloaded loop.
This commit is contained in:
Edward Hennis
2021-12-08 16:59:01 -05:00
committed by Nik Bougalis
parent ae9930b87d
commit b1c9b134dc
5 changed files with 185 additions and 136 deletions

View File

@@ -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