mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-29 09:55:49 +02:00
[CCoinsViewMemPool] track non-base coins and allow Reset
Temporary coins should not be available in separate subpackage submissions. Any mempool coins that are cached in m_view should be removed whenever mempool contents change, as they may be spent or no longer exist.
This commit is contained in:
@@ -982,6 +982,7 @@ bool CCoinsViewMemPool::GetCoin(const COutPoint &outpoint, Coin &coin) const {
|
||||
if (ptx) {
|
||||
if (outpoint.n < ptx->vout.size()) {
|
||||
coin = Coin(ptx->vout[outpoint.n], MEMPOOL_HEIGHT, false);
|
||||
m_non_base_coins.emplace(outpoint);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -994,8 +995,14 @@ void CCoinsViewMemPool::PackageAddTransaction(const CTransactionRef& tx)
|
||||
{
|
||||
for (unsigned int n = 0; n < tx->vout.size(); ++n) {
|
||||
m_temp_added.emplace(COutPoint(tx->GetHash(), n), Coin(tx->vout[n], MEMPOOL_HEIGHT, false));
|
||||
m_non_base_coins.emplace(COutPoint(tx->GetHash(), n));
|
||||
}
|
||||
}
|
||||
void CCoinsViewMemPool::Reset()
|
||||
{
|
||||
m_temp_added.clear();
|
||||
m_non_base_coins.clear();
|
||||
}
|
||||
|
||||
size_t CTxMemPool::DynamicMemoryUsage() const {
|
||||
LOCK(cs);
|
||||
|
||||
Reference in New Issue
Block a user