Extract method for incrementing witness heights
This commit is contained in:
parent
f6d0d5ec43
commit
4a0bc6047e
|
@ -827,6 +827,21 @@ void WitnessNoteIfMine(std::map<OutPoint, NoteData>& noteDataMap, int indexHeigh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename NoteDataMap>
|
||||||
|
void UpdateWitnessHeights(NoteDataMap& noteDataMap, int indexHeight, int64_t nWitnessCacheSize)
|
||||||
|
{
|
||||||
|
for (auto& item : noteDataMap) {
|
||||||
|
auto* nd = &(item.second);
|
||||||
|
if (nd->witnessHeight < indexHeight) {
|
||||||
|
nd->witnessHeight = indexHeight;
|
||||||
|
// Check the validity of the cache
|
||||||
|
// See comment in CopyPreviousWitnesses about validity.
|
||||||
|
assert(nWitnessCacheSize >= nd->witnesses.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||||
const CBlock* pblockIn,
|
const CBlock* pblockIn,
|
||||||
ZCIncrementalMerkleTree& tree)
|
ZCIncrementalMerkleTree& tree)
|
||||||
|
@ -872,15 +887,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
||||||
|
|
||||||
// Update witness heights
|
// Update witness heights
|
||||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||||
for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) {
|
::UpdateWitnessHeights(wtxItem.second.mapSproutNoteData, pindex->nHeight, nWitnessCacheSize);
|
||||||
SproutNoteData* nd = &(item.second);
|
|
||||||
if (nd->witnessHeight < pindex->nHeight) {
|
|
||||||
nd->witnessHeight = pindex->nHeight;
|
|
||||||
// Check the validity of the cache
|
|
||||||
// See earlier comment about validity.
|
|
||||||
assert(nWitnessCacheSize >= nd->witnesses.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For performance reasons, we write out the witness cache in
|
// For performance reasons, we write out the witness cache in
|
||||||
|
|
Loading…
Reference in New Issue