|
|
@ -675,6 +675,8 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, |
|
|
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) { |
|
|
|
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { |
|
|
|
CNoteData* nd = &(item.second); |
|
|
|
// Check the validity of the cache
|
|
|
|
assert(nWitnessCacheSize >= nd->witnesses.size()); |
|
|
|
if (nd->witnesses.size() > 0) { |
|
|
|
nd->witnesses.front().append(note_commitment); |
|
|
|
} |
|
|
@ -695,6 +697,13 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, |
|
|
|
if (nWitnessCacheSize < WITNESS_CACHE_SIZE) { |
|
|
|
nWitnessCacheSize += 1; |
|
|
|
} |
|
|
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) { |
|
|
|
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { |
|
|
|
CNoteData* nd = &(item.second); |
|
|
|
// Check the validity of the cache
|
|
|
|
assert(nWitnessCacheSize >= nd->witnesses.size()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (fFileBacked) { |
|
|
|
CWalletDB walletdb(strWalletFile); |
|
|
|
WriteWitnessCache(walletdb); |
|
|
@ -709,12 +718,21 @@ void CWallet::DecrementNoteWitnesses() |
|
|
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) { |
|
|
|
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { |
|
|
|
CNoteData* nd = &(item.second); |
|
|
|
// Check the validity of the cache
|
|
|
|
assert(nWitnessCacheSize >= nd->witnesses.size()); |
|
|
|
if (nd->witnesses.size() > 0) { |
|
|
|
nd->witnesses.pop_front(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
nWitnessCacheSize -= 1; |
|
|
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) { |
|
|
|
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) { |
|
|
|
CNoteData* nd = &(item.second); |
|
|
|
// Check the validity of the cache
|
|
|
|
assert(nWitnessCacheSize >= nd->witnesses.size()); |
|
|
|
} |
|
|
|
} |
|
|
|
// TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302)
|
|
|
|
assert(nWitnessCacheSize > 0); |
|
|
|
if (fFileBacked) { |
|
|
|