| 447 | * only returns the chunk feerates, not the corresponding transaction sets. */ |
| 448 | template<typename SetType> |
| 449 | std::vector<FeeFrac> ChunkLinearization(const DepGraph<SetType>& depgraph, std::span<const DepGraphIndex> linearization) noexcept |
| 450 | { |
| 451 | std::vector<FeeFrac> ret; |
| 452 | for (DepGraphIndex i : linearization) { |
| 453 | /** The new chunk to be added, initially a singleton. */ |
| 454 | auto new_chunk = depgraph.FeeRate(i); |
| 455 | // As long as the new chunk has a higher feerate than the last chunk so far, absorb it. |
| 456 | while (!ret.empty() && ByRatio{new_chunk} > ByRatio{ret.back()}) { |
| 457 | new_chunk += ret.back(); |
| 458 | ret.pop_back(); |
| 459 | } |
| 460 | // Actually move that new chunk into the chunking. |
| 461 | ret.push_back(std::move(new_chunk)); |
| 462 | } |
| 463 | return ret; |
| 464 | } |
| 465 | |
| 466 | /** Concept for function objects that return std::strong_ordering when invoked with two Args. */ |
| 467 | template<typename F, typename Arg> |