This PR takes advantage of our script check threads (used for block validation) in order to speed up transaction validation when adding to the mempool.
The motivation is to minimize the amount of time we might spend validating a single transaction. I think there are several approaches we could take to mitigate this concern, but this approach seemed straightforward to implement, and would be easy to revert if we later opted for a different solution (such as parallelizing our message handler or dropping transactions into some sort of queue for background processing).
This PR does introduce some behavior changes:
- we would no longer ban peers for transactions with invalid scripts (however, the status quo behavior is spotty and inconsistent in how it bans anyway, since the mandatory consensus flags set is years old and we stop at the first script execution error)
- we could relay transactions from a whitelisted peer that would cause us to be banned by an older peer (but
-whitelistforcerelay
now defaults to off, mitigating this concern)