diff --git a/src/miner.cpp b/src/miner.cpp index 1447e41c7a7..629ccc2844e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -425,7 +425,7 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::ve // transactions for block inclusion. sortedEntries.clear(); sortedEntries.insert(sortedEntries.begin(), package.begin(), package.end()); - std::sort(sortedEntries.begin(), sortedEntries.end(), CompareTxIterByAncestorCount()); + std::sort(sortedEntries.begin(), sortedEntries.end(), CompareTxIterByEntryTime()); } // This transaction selection algorithm orders the mempool based @@ -993,4 +993,4 @@ void ThreadStaker::operator()(std::vector args, CChainParams } } -} \ No newline at end of file +} diff --git a/src/miner.h b/src/miner.h index b20cc9adf96..b95ed88fc63 100644 --- a/src/miner.h +++ b/src/miner.h @@ -93,6 +93,16 @@ struct CompareTxIterByAncestorCount { } }; +// A comparator that sorts transactions based on tx entry time. +struct CompareTxIterByEntryTime { + bool operator()(const CTxMemPool::txiter &a, const CTxMemPool::txiter &b) const + { + if (a->GetTime() == b->GetTime()) + return CompareTxIterByAncestorCount()(a, b); + return CompareTxMemPoolEntryByEntryTime()(*a, *b); + } +}; + typedef boost::multi_index_container< CTxMemPoolModifiedEntry, boost::multi_index::indexed_by<