After #8524, CTxMemPool::check() can take much longer when the mempool is full of large transactions, such as the transactions used in pruning.py, because we're rehashing everything in the mempool. Consequently I've been seeing consistent test failures due to an RPC timeout at the point in pruning.py where 220 blocks are generated, because mempool.check() is called on each block, and many blocks need to be mined before the mempool is drained.
This PR works around the slowdown by splitting up the RPC call.
As mempool consistency checking is off by default on mainnet, I don't think this is an issue outside of the testing framework, so for now I don't think it's worth modifying/optimizing the work being done in CTxMemPool::check() over this.