Specifically describe anchors as Sprout anchors.
This commit is contained in:
parent
28d20bdb11
commit
d455828fdc
|
@ -51,7 +51,7 @@ uint256 CCoinsView::GetBestAnchor() const { return uint256(); };
|
||||||
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins,
|
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers) { return false; }
|
CNullifiersMap &mapSaplingNullifiers) { return false; }
|
||||||
bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
|
bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
|
||||||
|
@ -69,9 +69,9 @@ void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; }
|
||||||
bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins,
|
bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers) { return base->BatchWrite(mapCoins, hashBlock, hashAnchor, mapAnchors, mapSproutNullifiers, mapSaplingNullifiers); }
|
CNullifiersMap &mapSaplingNullifiers) { return base->BatchWrite(mapCoins, hashBlock, hashAnchor, mapSproutAnchors, mapSproutNullifiers, mapSaplingNullifiers); }
|
||||||
bool CCoinsViewBacked::GetStats(CCoinsStats &stats) const { return base->GetStats(stats); }
|
bool CCoinsViewBacked::GetStats(CCoinsStats &stats) const { return base->GetStats(stats); }
|
||||||
|
|
||||||
CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {}
|
CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {}
|
||||||
|
@ -85,7 +85,7 @@ CCoinsViewCache::~CCoinsViewCache()
|
||||||
|
|
||||||
size_t CCoinsViewCache::DynamicMemoryUsage() const {
|
size_t CCoinsViewCache::DynamicMemoryUsage() const {
|
||||||
return memusage::DynamicUsage(cacheCoins) +
|
return memusage::DynamicUsage(cacheCoins) +
|
||||||
memusage::DynamicUsage(cacheAnchors) +
|
memusage::DynamicUsage(cacheSproutAnchors) +
|
||||||
memusage::DynamicUsage(cacheSproutNullifiers) +
|
memusage::DynamicUsage(cacheSproutNullifiers) +
|
||||||
memusage::DynamicUsage(cacheSaplingNullifiers) +
|
memusage::DynamicUsage(cacheSaplingNullifiers) +
|
||||||
cachedCoinsUsage;
|
cachedCoinsUsage;
|
||||||
|
@ -111,8 +111,8 @@ CCoinsMap::const_iterator CCoinsViewCache::FetchCoins(const uint256 &txid) const
|
||||||
|
|
||||||
|
|
||||||
bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const {
|
bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const {
|
||||||
CAnchorsMap::const_iterator it = cacheAnchors.find(rt);
|
CAnchorsSproutMap::const_iterator it = cacheSproutAnchors.find(rt);
|
||||||
if (it != cacheAnchors.end()) {
|
if (it != cacheSproutAnchors.end()) {
|
||||||
if (it->second.entered) {
|
if (it->second.entered) {
|
||||||
tree = it->second.tree;
|
tree = it->second.tree;
|
||||||
return true;
|
return true;
|
||||||
|
@ -125,7 +125,7 @@ bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tr
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnchorsMap::iterator ret = cacheAnchors.insert(std::make_pair(rt, CAnchorsCacheEntry())).first;
|
CAnchorsSproutMap::iterator ret = cacheSproutAnchors.insert(std::make_pair(rt, CAnchorsSproutCacheEntry())).first;
|
||||||
ret->second.entered = true;
|
ret->second.entered = true;
|
||||||
ret->second.tree = tree;
|
ret->second.tree = tree;
|
||||||
cachedCoinsUsage += ret->second.tree.DynamicMemoryUsage();
|
cachedCoinsUsage += ret->second.tree.DynamicMemoryUsage();
|
||||||
|
@ -164,17 +164,17 @@ void CCoinsViewCache::PushAnchor(const ZCIncrementalMerkleTree &tree) {
|
||||||
auto currentRoot = GetBestAnchor();
|
auto currentRoot = GetBestAnchor();
|
||||||
|
|
||||||
// We don't want to overwrite an anchor we already have.
|
// We don't want to overwrite an anchor we already have.
|
||||||
// This occurs when a block doesn't modify mapAnchors at all,
|
// This occurs when a block doesn't modify mapSproutAnchors at all,
|
||||||
// because there are no joinsplits. We could get around this a
|
// because there are no joinsplits. We could get around this a
|
||||||
// different way (make all blocks modify mapAnchors somehow)
|
// different way (make all blocks modify mapSproutAnchors somehow)
|
||||||
// but this is simpler to reason about.
|
// but this is simpler to reason about.
|
||||||
if (currentRoot != newrt) {
|
if (currentRoot != newrt) {
|
||||||
auto insertRet = cacheAnchors.insert(std::make_pair(newrt, CAnchorsCacheEntry()));
|
auto insertRet = cacheSproutAnchors.insert(std::make_pair(newrt, CAnchorsSproutCacheEntry()));
|
||||||
CAnchorsMap::iterator ret = insertRet.first;
|
CAnchorsSproutMap::iterator ret = insertRet.first;
|
||||||
|
|
||||||
ret->second.entered = true;
|
ret->second.entered = true;
|
||||||
ret->second.tree = tree;
|
ret->second.tree = tree;
|
||||||
ret->second.flags = CAnchorsCacheEntry::DIRTY;
|
ret->second.flags = CAnchorsSproutCacheEntry::DIRTY;
|
||||||
|
|
||||||
if (insertRet.second) {
|
if (insertRet.second) {
|
||||||
// An insert took place
|
// An insert took place
|
||||||
|
@ -200,10 +200,10 @@ void CCoinsViewCache::PopAnchor(const uint256 &newrt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the anchor as unentered, removing it from view
|
// Mark the anchor as unentered, removing it from view
|
||||||
cacheAnchors[currentRoot].entered = false;
|
cacheSproutAnchors[currentRoot].entered = false;
|
||||||
|
|
||||||
// Mark the cache entry as dirty so it's propagated
|
// Mark the cache entry as dirty so it's propagated
|
||||||
cacheAnchors[currentRoot].flags = CAnchorsCacheEntry::DIRTY;
|
cacheSproutAnchors[currentRoot].flags = CAnchorsSproutCacheEntry::DIRTY;
|
||||||
|
|
||||||
// Mark the new root as the best anchor
|
// Mark the new root as the best anchor
|
||||||
hashAnchor = newrt;
|
hashAnchor = newrt;
|
||||||
|
@ -315,7 +315,7 @@ void BatchWriteNullifiers(CNullifiersMap &mapNullifiers, CNullifiersMap &cacheNu
|
||||||
bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlockIn,
|
const uint256 &hashBlockIn,
|
||||||
const uint256 &hashAnchorIn,
|
const uint256 &hashAnchorIn,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers) {
|
CNullifiersMap &mapSaplingNullifiers) {
|
||||||
assert(!hasModifier);
|
assert(!hasModifier);
|
||||||
|
@ -354,29 +354,29 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
||||||
mapCoins.erase(itOld);
|
mapCoins.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CAnchorsMap::iterator child_it = mapAnchors.begin(); child_it != mapAnchors.end();)
|
for (CAnchorsSproutMap::iterator child_it = mapSproutAnchors.begin(); child_it != mapSproutAnchors.end();)
|
||||||
{
|
{
|
||||||
if (child_it->second.flags & CAnchorsCacheEntry::DIRTY) {
|
if (child_it->second.flags & CAnchorsSproutCacheEntry::DIRTY) {
|
||||||
CAnchorsMap::iterator parent_it = cacheAnchors.find(child_it->first);
|
CAnchorsSproutMap::iterator parent_it = cacheSproutAnchors.find(child_it->first);
|
||||||
|
|
||||||
if (parent_it == cacheAnchors.end()) {
|
if (parent_it == cacheSproutAnchors.end()) {
|
||||||
CAnchorsCacheEntry& entry = cacheAnchors[child_it->first];
|
CAnchorsSproutCacheEntry& entry = cacheSproutAnchors[child_it->first];
|
||||||
entry.entered = child_it->second.entered;
|
entry.entered = child_it->second.entered;
|
||||||
entry.tree = child_it->second.tree;
|
entry.tree = child_it->second.tree;
|
||||||
entry.flags = CAnchorsCacheEntry::DIRTY;
|
entry.flags = CAnchorsSproutCacheEntry::DIRTY;
|
||||||
|
|
||||||
cachedCoinsUsage += entry.tree.DynamicMemoryUsage();
|
cachedCoinsUsage += entry.tree.DynamicMemoryUsage();
|
||||||
} else {
|
} else {
|
||||||
if (parent_it->second.entered != child_it->second.entered) {
|
if (parent_it->second.entered != child_it->second.entered) {
|
||||||
// The parent may have removed the entry.
|
// The parent may have removed the entry.
|
||||||
parent_it->second.entered = child_it->second.entered;
|
parent_it->second.entered = child_it->second.entered;
|
||||||
parent_it->second.flags |= CAnchorsCacheEntry::DIRTY;
|
parent_it->second.flags |= CAnchorsSproutCacheEntry::DIRTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnchorsMap::iterator itOld = child_it++;
|
CAnchorsSproutMap::iterator itOld = child_it++;
|
||||||
mapAnchors.erase(itOld);
|
mapSproutAnchors.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
::BatchWriteNullifiers(mapSproutNullifiers, cacheSproutNullifiers);
|
::BatchWriteNullifiers(mapSproutNullifiers, cacheSproutNullifiers);
|
||||||
|
@ -388,9 +388,9 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCoinsViewCache::Flush() {
|
bool CCoinsViewCache::Flush() {
|
||||||
bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashAnchor, cacheAnchors, cacheSproutNullifiers, cacheSaplingNullifiers);
|
bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashAnchor, cacheSproutAnchors, cacheSproutNullifiers, cacheSaplingNullifiers);
|
||||||
cacheCoins.clear();
|
cacheCoins.clear();
|
||||||
cacheAnchors.clear();
|
cacheSproutAnchors.clear();
|
||||||
cacheSproutNullifiers.clear();
|
cacheSproutNullifiers.clear();
|
||||||
cacheSaplingNullifiers.clear();
|
cacheSaplingNullifiers.clear();
|
||||||
cachedCoinsUsage = 0;
|
cachedCoinsUsage = 0;
|
||||||
|
|
14
src/coins.h
14
src/coins.h
|
@ -273,7 +273,7 @@ struct CCoinsCacheEntry
|
||||||
CCoinsCacheEntry() : coins(), flags(0) {}
|
CCoinsCacheEntry() : coins(), flags(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CAnchorsCacheEntry
|
struct CAnchorsSproutCacheEntry
|
||||||
{
|
{
|
||||||
bool entered; // This will be false if the anchor is removed from the cache
|
bool entered; // This will be false if the anchor is removed from the cache
|
||||||
ZCIncrementalMerkleTree tree; // The tree itself
|
ZCIncrementalMerkleTree tree; // The tree itself
|
||||||
|
@ -283,7 +283,7 @@ struct CAnchorsCacheEntry
|
||||||
DIRTY = (1 << 0), // This cache entry is potentially different from the version in the parent view.
|
DIRTY = (1 << 0), // This cache entry is potentially different from the version in the parent view.
|
||||||
};
|
};
|
||||||
|
|
||||||
CAnchorsCacheEntry() : entered(false), flags(0) {}
|
CAnchorsSproutCacheEntry() : entered(false), flags(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CNullifiersCacheEntry
|
struct CNullifiersCacheEntry
|
||||||
|
@ -305,7 +305,7 @@ enum ShieldedType
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef boost::unordered_map<uint256, CCoinsCacheEntry, CCoinsKeyHasher> CCoinsMap;
|
typedef boost::unordered_map<uint256, CCoinsCacheEntry, CCoinsKeyHasher> CCoinsMap;
|
||||||
typedef boost::unordered_map<uint256, CAnchorsCacheEntry, CCoinsKeyHasher> CAnchorsMap;
|
typedef boost::unordered_map<uint256, CAnchorsSproutCacheEntry, CCoinsKeyHasher> CAnchorsSproutMap;
|
||||||
typedef boost::unordered_map<uint256, CNullifiersCacheEntry, CCoinsKeyHasher> CNullifiersMap;
|
typedef boost::unordered_map<uint256, CNullifiersCacheEntry, CCoinsKeyHasher> CNullifiersMap;
|
||||||
|
|
||||||
struct CCoinsStats
|
struct CCoinsStats
|
||||||
|
@ -350,7 +350,7 @@ public:
|
||||||
virtual bool BatchWrite(CCoinsMap &mapCoins,
|
virtual bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers);
|
CNullifiersMap &mapSaplingNullifiers);
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ public:
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers);
|
CNullifiersMap &mapSaplingNullifiers);
|
||||||
bool GetStats(CCoinsStats &stats) const;
|
bool GetStats(CCoinsStats &stats) const;
|
||||||
|
@ -424,7 +424,7 @@ protected:
|
||||||
mutable uint256 hashBlock;
|
mutable uint256 hashBlock;
|
||||||
mutable CCoinsMap cacheCoins;
|
mutable CCoinsMap cacheCoins;
|
||||||
mutable uint256 hashAnchor;
|
mutable uint256 hashAnchor;
|
||||||
mutable CAnchorsMap cacheAnchors;
|
mutable CAnchorsSproutMap cacheSproutAnchors;
|
||||||
mutable CNullifiersMap cacheSproutNullifiers;
|
mutable CNullifiersMap cacheSproutNullifiers;
|
||||||
mutable CNullifiersMap cacheSaplingNullifiers;
|
mutable CNullifiersMap cacheSaplingNullifiers;
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ public:
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers);
|
CNullifiersMap &mapSaplingNullifiers);
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers) {
|
CNullifiersMap &mapSaplingNullifiers) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap saplingNullifiersMap) {
|
CNullifiersMap saplingNullifiersMap) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class CCoinsViewTest : public CCoinsView
|
||||||
uint256 hashBestBlock_;
|
uint256 hashBestBlock_;
|
||||||
uint256 hashBestAnchor_;
|
uint256 hashBestAnchor_;
|
||||||
std::map<uint256, CCoins> map_;
|
std::map<uint256, CCoins> map_;
|
||||||
std::map<uint256, ZCIncrementalMerkleTree> mapAnchors_;
|
std::map<uint256, ZCIncrementalMerkleTree> mapSproutAnchors_;
|
||||||
std::map<uint256, bool> mapSproutNullifiers_;
|
std::map<uint256, bool> mapSproutNullifiers_;
|
||||||
std::map<uint256, bool> mapSaplingNullifiers_;
|
std::map<uint256, bool> mapSaplingNullifiers_;
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint256, ZCIncrementalMerkleTree>::const_iterator it = mapAnchors_.find(rt);
|
std::map<uint256, ZCIncrementalMerkleTree>::const_iterator it = mapSproutAnchors_.find(rt);
|
||||||
if (it == mapAnchors_.end()) {
|
if (it == mapSproutAnchors_.end()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
tree = it->second;
|
tree = it->second;
|
||||||
|
@ -115,7 +115,7 @@ public:
|
||||||
bool BatchWrite(CCoinsMap& mapCoins,
|
bool BatchWrite(CCoinsMap& mapCoins,
|
||||||
const uint256& hashBlock,
|
const uint256& hashBlock,
|
||||||
const uint256& hashAnchor,
|
const uint256& hashAnchor,
|
||||||
CAnchorsMap& mapAnchors,
|
CAnchorsSproutMap& mapSproutAnchors,
|
||||||
CNullifiersMap& mapSproutNullifiers,
|
CNullifiersMap& mapSproutNullifiers,
|
||||||
CNullifiersMap& mapSaplingNullifiers)
|
CNullifiersMap& mapSaplingNullifiers)
|
||||||
{
|
{
|
||||||
|
@ -127,23 +127,23 @@ public:
|
||||||
}
|
}
|
||||||
mapCoins.erase(it++);
|
mapCoins.erase(it++);
|
||||||
}
|
}
|
||||||
for (CAnchorsMap::iterator it = mapAnchors.begin(); it != mapAnchors.end(); ) {
|
for (CAnchorsSproutMap::iterator it = mapSproutAnchors.begin(); it != mapSproutAnchors.end(); ) {
|
||||||
if (it->second.entered) {
|
if (it->second.entered) {
|
||||||
std::map<uint256, ZCIncrementalMerkleTree>::iterator ret =
|
std::map<uint256, ZCIncrementalMerkleTree>::iterator ret =
|
||||||
mapAnchors_.insert(std::make_pair(it->first, ZCIncrementalMerkleTree())).first;
|
mapSproutAnchors_.insert(std::make_pair(it->first, ZCIncrementalMerkleTree())).first;
|
||||||
|
|
||||||
ret->second = it->second.tree;
|
ret->second = it->second.tree;
|
||||||
} else {
|
} else {
|
||||||
mapAnchors_.erase(it->first);
|
mapSproutAnchors_.erase(it->first);
|
||||||
}
|
}
|
||||||
mapAnchors.erase(it++);
|
mapSproutAnchors.erase(it++);
|
||||||
}
|
}
|
||||||
|
|
||||||
BatchWriteNullifiers(mapSproutNullifiers, mapSproutNullifiers_);
|
BatchWriteNullifiers(mapSproutNullifiers, mapSproutNullifiers_);
|
||||||
BatchWriteNullifiers(mapSaplingNullifiers, mapSaplingNullifiers_);
|
BatchWriteNullifiers(mapSaplingNullifiers, mapSaplingNullifiers_);
|
||||||
|
|
||||||
mapCoins.clear();
|
mapCoins.clear();
|
||||||
mapAnchors.clear();
|
mapSproutAnchors.clear();
|
||||||
hashBestBlock_ = hashBlock;
|
hashBestBlock_ = hashBlock;
|
||||||
hashBestAnchor_ = hashAnchor;
|
hashBestAnchor_ = hashAnchor;
|
||||||
return true;
|
return true;
|
||||||
|
@ -161,7 +161,7 @@ public:
|
||||||
{
|
{
|
||||||
// Manually recompute the dynamic usage of the whole data, and compare it.
|
// Manually recompute the dynamic usage of the whole data, and compare it.
|
||||||
size_t ret = memusage::DynamicUsage(cacheCoins) +
|
size_t ret = memusage::DynamicUsage(cacheCoins) +
|
||||||
memusage::DynamicUsage(cacheAnchors) +
|
memusage::DynamicUsage(cacheSproutAnchors) +
|
||||||
memusage::DynamicUsage(cacheSproutNullifiers) +
|
memusage::DynamicUsage(cacheSproutNullifiers) +
|
||||||
memusage::DynamicUsage(cacheSaplingNullifiers);
|
memusage::DynamicUsage(cacheSaplingNullifiers);
|
||||||
for (CCoinsMap::iterator it = cacheCoins.begin(); it != cacheCoins.end(); it++) {
|
for (CCoinsMap::iterator it = cacheCoins.begin(); it != cacheCoins.end(); it++) {
|
||||||
|
|
10
src/txdb.cpp
10
src/txdb.cpp
|
@ -108,7 +108,7 @@ void BatchWriteNullifiers(CDBBatch& batch, CNullifiersMap& mapToUse, const char&
|
||||||
bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers) {
|
CNullifiersMap &mapSaplingNullifiers) {
|
||||||
CDBBatch batch(db);
|
CDBBatch batch(db);
|
||||||
|
@ -127,8 +127,8 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
||||||
mapCoins.erase(itOld);
|
mapCoins.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CAnchorsMap::iterator it = mapAnchors.begin(); it != mapAnchors.end();) {
|
for (CAnchorsSproutMap::iterator it = mapSproutAnchors.begin(); it != mapSproutAnchors.end();) {
|
||||||
if (it->second.flags & CAnchorsCacheEntry::DIRTY) {
|
if (it->second.flags & CAnchorsSproutCacheEntry::DIRTY) {
|
||||||
if (!it->second.entered)
|
if (!it->second.entered)
|
||||||
batch.Erase(make_pair(DB_ANCHOR, it->first));
|
batch.Erase(make_pair(DB_ANCHOR, it->first));
|
||||||
else {
|
else {
|
||||||
|
@ -136,8 +136,8 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
||||||
}
|
}
|
||||||
// TODO: changed++?
|
// TODO: changed++?
|
||||||
}
|
}
|
||||||
CAnchorsMap::iterator itOld = it++;
|
CAnchorsSproutMap::iterator itOld = it++;
|
||||||
mapAnchors.erase(itOld);
|
mapSproutAnchors.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
::BatchWriteNullifiers(batch, mapSproutNullifiers, DB_NULLIFIER);
|
::BatchWriteNullifiers(batch, mapSproutNullifiers, DB_NULLIFIER);
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers);
|
CNullifiersMap &mapSaplingNullifiers);
|
||||||
bool GetStats(CCoinsStats &stats) const;
|
bool GetStats(CCoinsStats &stats) const;
|
||||||
|
|
|
@ -381,7 +381,7 @@ public:
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap& mapSaplingNullifiers) {
|
CNullifiersMap& mapSaplingNullifiers) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue