Only take cs_main lock in GetSaplingSpendDepth

We do not seem to need this lock for the entire DecrementNoteWitnesses function,
we need it only when calling GetSaplingSpendDepth. Also protects against
the case in the future where some code without cs_main calls GetSaplingSpendDepth.
This commit is contained in:
Duke
2024-09-13 04:11:38 -04:00
parent 72c530d281
commit be3641158a

View File

@@ -887,6 +887,8 @@ bool CWallet::IsSaplingSpent(const uint256& nullifier) const {
}
unsigned int CWallet::GetSaplingSpendDepth(const uint256& nullifier) const {
LOCK(cs_main);
pair<TxNullifiers::const_iterator, TxNullifiers::const_iterator> range;
range = mapTxSaplingNullifiers.equal_range(nullifier);
@@ -977,10 +979,11 @@ void CWallet::ClearNoteWitnessCache()
void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
{
LOCK2(cs_main, cs_wallet);
extern int32_t HUSH_REWIND;
LOCK(cs_wallet);
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
//Sapling
for (auto& item : wtxItem.second.mapSaplingNoteData) {