Auto merge of #1547 - daira:1378-witness-cache-assertion-failure.1, r=bitcartel
Add more precise assertions in IncrementNoteWitnesses Part of #1378
This commit is contained in:
commit
fd23341f1e
|
@ -654,6 +654,9 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nWitnessCacheSize < WITNESS_CACHE_SIZE) {
|
||||||
|
nWitnessCacheSize += 1;
|
||||||
|
}
|
||||||
|
|
||||||
const CBlock* pblock {pblockIn};
|
const CBlock* pblock {pblockIn};
|
||||||
CBlock block;
|
CBlock block;
|
||||||
|
@ -675,6 +678,8 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||||
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) {
|
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) {
|
||||||
CNoteData* nd = &(item.second);
|
CNoteData* nd = &(item.second);
|
||||||
|
// Check the validity of the cache
|
||||||
|
assert(nWitnessCacheSize >= nd->witnesses.size());
|
||||||
if (nd->witnesses.size() > 0) {
|
if (nd->witnesses.size() > 0) {
|
||||||
nd->witnesses.front().append(note_commitment);
|
nd->witnesses.front().append(note_commitment);
|
||||||
}
|
}
|
||||||
|
@ -685,15 +690,22 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||||
if (txIsOurs) {
|
if (txIsOurs) {
|
||||||
JSOutPoint jsoutpt {hash, i, j};
|
JSOutPoint jsoutpt {hash, i, j};
|
||||||
if (mapWallet[hash].mapNoteData.count(jsoutpt)) {
|
if (mapWallet[hash].mapNoteData.count(jsoutpt)) {
|
||||||
mapWallet[hash].mapNoteData[jsoutpt].witnesses.push_front(
|
CNoteData* nd = &(mapWallet[hash].mapNoteData[jsoutpt]);
|
||||||
tree.witness());
|
assert(nd->witnesses.size() == 0);
|
||||||
|
nd->witnesses.push_front(tree.witness());
|
||||||
|
// Check the validity of the cache
|
||||||
|
assert(nWitnessCacheSize >= nd->witnesses.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nWitnessCacheSize < WITNESS_CACHE_SIZE) {
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||||
nWitnessCacheSize += 1;
|
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) {
|
if (fFileBacked) {
|
||||||
CWalletDB walletdb(strWalletFile);
|
CWalletDB walletdb(strWalletFile);
|
||||||
|
@ -709,12 +721,21 @@ void CWallet::DecrementNoteWitnesses()
|
||||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||||
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) {
|
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) {
|
||||||
CNoteData* nd = &(item.second);
|
CNoteData* nd = &(item.second);
|
||||||
|
// Check the validity of the cache
|
||||||
|
assert(nWitnessCacheSize >= nd->witnesses.size());
|
||||||
if (nd->witnesses.size() > 0) {
|
if (nd->witnesses.size() > 0) {
|
||||||
nd->witnesses.pop_front();
|
nd->witnesses.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nWitnessCacheSize -= 1;
|
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)
|
// TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302)
|
||||||
assert(nWitnessCacheSize > 0);
|
assert(nWitnessCacheSize > 0);
|
||||||
if (fFileBacked) {
|
if (fFileBacked) {
|
||||||
|
|
Loading…
Reference in New Issue