Improve the performance of removeForBlock
Summary:
This is inspired by bchn#1188, though most of the changes are irrelevant for us due to being already fixed by code changes. Also our mutex requirement is much better so some optimization are simply not worth it either.
In the end only a couple optimizations remain, bot in removeForBlock:
- The removeConflicts call can be skipped for txs coming from the mempool that are guaranteed to not have any conflict
- The whole mempool cleanup is needless if the mempool is empty, which is especially useful during IBD. An extra comment is added here to explain why the rolling fee feature can be skipped with no change in behavior.
Test Plan:
ninja all check-all
Run IBD.
Reviewers: #bitcoin_abc, sdulfari
Reviewed By: #bitcoin_abc, sdulfari
Subscribers: sdulfari
Differential Revision: https://reviews.bitcoinabc.org/D13214