Compare by min(ancestor feerate, individual feerate), then txid Under the ancestor-based mining approach, high-feerate children can pay for parents, but high-feerate parents do not incentive inclusion of their children. Therefore the mining algorithm only considers transactions for inclusion on basis of the minimum of their own feerate or their ancestor feerate.
| 178 | // parents do not incentive inclusion of their children. Therefore the mining algorithm only considers |
| 179 | // transactions for inclusion on basis of the minimum of their own feerate or their ancestor feerate. |
| 180 | struct AncestorFeerateComparator |
| 181 | { |
| 182 | template<typename I> |
| 183 | bool operator()(const I& a, const I& b) const { |
| 184 | auto min_feerate = [](const MiniMinerMempoolEntry& e) -> FeeFrac { |
| 185 | FeeFrac self_feerate(e.GetModifiedFee(), e.GetTxSize()); |
| 186 | FeeFrac ancestor_feerate(e.GetModFeesWithAncestors(), e.GetSizeWithAncestors()); |
| 187 | return std::min<ByRatioNegSize<FeeFrac>>(ancestor_feerate, self_feerate); |
| 188 | }; |
| 189 | FeeFrac a_feerate{min_feerate(a->second)}; |
| 190 | FeeFrac b_feerate{min_feerate(b->second)}; |
| 191 | if (a_feerate != b_feerate) { |
| 192 | return ByRatioNegSize{a_feerate} > ByRatioNegSize{b_feerate}; |
| 193 | } |
| 194 | // Use txid as tiebreaker for stable sorting |
| 195 | return a->first < b->first; |
| 196 | } |
| 197 | }; |
| 198 | |
| 199 | void MiniMiner::DeleteAncestorPackage(const std::set<MockEntryMap::iterator, IteratorComparator>& ancestors) |
| 200 | { |