Skip to content

Commit ef17855

Browse files
committed
[Mempool][Sapling] Introduce CTxMemPool::checkNullifiers
1 parent db86e92 commit ef17855

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/txmempool.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,24 @@ void CTxMemPool::check(const CCoinsViewCache* pcoins) const
727727
assert(it->first == it->second.ptx->vin[it->second.n].prevout);
728728
}
729729

730+
// Consistency check for sapling nullifiers
731+
checkNullifiers();
732+
730733
assert(totalTxSize == checkTotal);
731734
assert(innerUsage == cachedInnerUsage);
732735
}
733736

737+
void CTxMemPool::checkNullifiers() const
738+
{
739+
for (const auto& it : mapSaplingNullifiers) {
740+
const uint256& hash = it.second->GetHash();
741+
const auto& findTx = mapTx.find(hash);
742+
assert(findTx != mapTx.end());
743+
const CTransaction& tx = findTx->GetTx();
744+
assert(&tx == it.second);
745+
}
746+
}
747+
734748
void CTxMemPool::queryHashes(std::vector<uint256>& vtxid)
735749
{
736750
vtxid.clear();

src/txmempool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ class CTxMemPool
469469
*/
470470
void check(const CCoinsViewCache *pcoins) const;
471471
void setSanityCheck(double dFrequency = 1.0) { nCheckFrequency = dFrequency * 4294967295.0; }
472+
void checkNullifiers() const;
472473

473474
// addUnchecked must updated state for all ancestors of a given transaction,
474475
// to track size/count of descendant transactions. First version of

0 commit comments

Comments
 (0)