This PR is a subpart of #20833 which enables package validation through testmempoolaccept
.
The first commit addresses some leftover comments from #21062.
When validating unconfirmed transactions, we want to account for all coins brought in from disk so we can uncache them if the tx is invalid. The disconnection of CCoinsView
s right now doesn’t quite achieve what’s it’s trying to do (prevent MemPoolAccept
from unnecessarily accessing the coins cache and forgetting to uncache later). This PR improves it by doing 2 things:
(1) Disconnect m_viewmempool
from the coins cache when we don’t need it to be connected.
(2) Make MemPoolAccept
destructor clean up after itself by uncaching coins accessed, instead of leaving it up to the caller. Only leave the coins cached when a transaction is accepted to mempool. In the future, if someone edits the MemPoolAccept
class and forgets to consider uncaching, the default behavior is to uncache (which is safer).