Something like this might be general enough to be useful(Uncle eviction?):
If proposed chunk is too large for cluster by (remaining_size, remaining_count):
- add all existing chunks to minheap by CFR
- While heap not empty, pop chunk:
For each transaction in chunk(in reverse topo order):
if in proposed chunks’ ancestor set: skip
else mark for eviction and reduce remaining_size by tx size and remaining_count by 1 If remaining_size <= 0 and remaining_count <= 0: break - If anything was marked for eviction: Do diagram check (don’t check remaining_*, maybe we split clusters accidentally?)
You could also restrict the space of transactions to evict to something more “local” like the descendants of the proposed chunk’s ancestors’(not including the ancestor set itself). This should allow eviction in every case still if the new chunk’s fees are high enough, while acting a bit more “locally”.
These should allow improvements to the mempool with O(nlogn) processing, and no resubmission of transactions? Doesn’t solve incremental relay pins of course.