Rename CSerialsMap to CNullifiersMap.
This commit is contained in:
@@ -50,7 +50,7 @@ bool CCoinsView::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials) { return false; }
|
CNullifiersMap &mapSerials) { return false; }
|
||||||
bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
|
bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials) { return base->BatchWrite(mapCoins, hashBlock, hashAnchor, mapAnchors, mapSerials); }
|
CNullifiersMap &mapSerials) { return base->BatchWrite(mapCoins, hashBlock, hashAnchor, mapAnchors, mapSerials); }
|
||||||
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()) {}
|
||||||
@@ -129,7 +129,7 @@ bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tr
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CCoinsViewCache::GetNullifier(const uint256 &serial) const {
|
bool CCoinsViewCache::GetNullifier(const uint256 &serial) const {
|
||||||
CSerialsMap::iterator it = cacheSerials.find(serial);
|
CNullifiersMap::iterator it = cacheSerials.find(serial);
|
||||||
if (it != cacheSerials.end())
|
if (it != cacheSerials.end())
|
||||||
return it->second.entered;
|
return it->second.entered;
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ void CCoinsViewCache::PopAnchor(const uint256 &newrt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CCoinsViewCache::SetNullifier(const uint256 &serial, bool spent) {
|
void CCoinsViewCache::SetNullifier(const uint256 &serial, bool spent) {
|
||||||
std::pair<CSerialsMap::iterator, bool> ret = cacheSerials.insert(std::make_pair(serial, CSerialsCacheEntry()));
|
std::pair<CNullifiersMap::iterator, bool> ret = cacheSerials.insert(std::make_pair(serial, CSerialsCacheEntry()));
|
||||||
ret.first->second.entered = spent;
|
ret.first->second.entered = spent;
|
||||||
ret.first->second.flags |= CSerialsCacheEntry::DIRTY;
|
ret.first->second.flags |= CSerialsCacheEntry::DIRTY;
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
const uint256 &hashBlockIn,
|
const uint256 &hashBlockIn,
|
||||||
const uint256 &hashAnchorIn,
|
const uint256 &hashAnchorIn,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials) {
|
CNullifiersMap &mapSerials) {
|
||||||
assert(!hasModifier);
|
assert(!hasModifier);
|
||||||
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
|
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) {
|
||||||
if (it->second.flags & CCoinsCacheEntry::DIRTY) { // Ignore non-dirty entries (optimization).
|
if (it->second.flags & CCoinsCacheEntry::DIRTY) { // Ignore non-dirty entries (optimization).
|
||||||
@@ -326,10 +326,10 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
mapAnchors.erase(itOld);
|
mapAnchors.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CSerialsMap::iterator child_it = mapSerials.begin(); child_it != mapSerials.end();)
|
for (CNullifiersMap::iterator child_it = mapSerials.begin(); child_it != mapSerials.end();)
|
||||||
{
|
{
|
||||||
if (child_it->second.flags & CSerialsCacheEntry::DIRTY) { // Ignore non-dirty entries (optimization).
|
if (child_it->second.flags & CSerialsCacheEntry::DIRTY) { // Ignore non-dirty entries (optimization).
|
||||||
CSerialsMap::iterator parent_it = cacheSerials.find(child_it->first);
|
CNullifiersMap::iterator parent_it = cacheSerials.find(child_it->first);
|
||||||
|
|
||||||
if (parent_it == cacheSerials.end()) {
|
if (parent_it == cacheSerials.end()) {
|
||||||
if (child_it->second.entered) {
|
if (child_it->second.entered) {
|
||||||
@@ -347,7 +347,7 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CSerialsMap::iterator itOld = child_it++;
|
CNullifiersMap::iterator itOld = child_it++;
|
||||||
mapSerials.erase(itOld);
|
mapSerials.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/coins.h
10
src/coins.h
@@ -323,7 +323,7 @@ struct CSerialsCacheEntry
|
|||||||
|
|
||||||
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, CAnchorsCacheEntry, CCoinsKeyHasher> CAnchorsMap;
|
||||||
typedef boost::unordered_map<uint256, CSerialsCacheEntry, CCoinsKeyHasher> CSerialsMap;
|
typedef boost::unordered_map<uint256, CSerialsCacheEntry, CCoinsKeyHasher> CNullifiersMap;
|
||||||
|
|
||||||
struct CCoinsStats
|
struct CCoinsStats
|
||||||
{
|
{
|
||||||
@@ -368,7 +368,7 @@ public:
|
|||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials);
|
CNullifiersMap &mapSerials);
|
||||||
|
|
||||||
//! Calculate statistics about the unspent transaction output set
|
//! Calculate statistics about the unspent transaction output set
|
||||||
virtual bool GetStats(CCoinsStats &stats) const;
|
virtual bool GetStats(CCoinsStats &stats) const;
|
||||||
@@ -397,7 +397,7 @@ public:
|
|||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials);
|
CNullifiersMap &mapSerials);
|
||||||
bool GetStats(CCoinsStats &stats) const;
|
bool GetStats(CCoinsStats &stats) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ protected:
|
|||||||
mutable CCoinsMap cacheCoins;
|
mutable CCoinsMap cacheCoins;
|
||||||
mutable uint256 hashAnchor;
|
mutable uint256 hashAnchor;
|
||||||
mutable CAnchorsMap cacheAnchors;
|
mutable CAnchorsMap cacheAnchors;
|
||||||
mutable CSerialsMap cacheSerials;
|
mutable CNullifiersMap cacheSerials;
|
||||||
|
|
||||||
/* Cached dynamic memory usage for the inner CCoins objects. */
|
/* Cached dynamic memory usage for the inner CCoins objects. */
|
||||||
mutable size_t cachedCoinsUsage;
|
mutable size_t cachedCoinsUsage;
|
||||||
@@ -461,7 +461,7 @@ public:
|
|||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials);
|
CNullifiersMap &mapSerials);
|
||||||
|
|
||||||
|
|
||||||
// Adds the tree to mapAnchors and sets the current commitment
|
// Adds the tree to mapAnchors and sets the current commitment
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public:
|
|||||||
const uint256& hashBlock,
|
const uint256& hashBlock,
|
||||||
const uint256& hashAnchor,
|
const uint256& hashAnchor,
|
||||||
CAnchorsMap& mapAnchors,
|
CAnchorsMap& mapAnchors,
|
||||||
CSerialsMap& mapSerials)
|
CNullifiersMap& mapSerials)
|
||||||
{
|
{
|
||||||
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) {
|
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) {
|
||||||
map_[it->first] = it->second.coins;
|
map_[it->first] = it->second.coins;
|
||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
}
|
}
|
||||||
mapAnchors.erase(it++);
|
mapAnchors.erase(it++);
|
||||||
}
|
}
|
||||||
for (CSerialsMap::iterator it = mapSerials.begin(); it != mapSerials.end(); ) {
|
for (CNullifiersMap::iterator it = mapSerials.begin(); it != mapSerials.end(); ) {
|
||||||
if (it->second.entered) {
|
if (it->second.entered) {
|
||||||
mapSerials_[it->first] = true;
|
mapSerials_[it->first] = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials) {
|
CNullifiersMap &mapSerials) {
|
||||||
CLevelDBBatch batch;
|
CLevelDBBatch batch;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
size_t changed = 0;
|
size_t changed = 0;
|
||||||
@@ -137,12 +137,12 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
mapAnchors.erase(itOld);
|
mapAnchors.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CSerialsMap::iterator it = mapSerials.begin(); it != mapSerials.end();) {
|
for (CNullifiersMap::iterator it = mapSerials.begin(); it != mapSerials.end();) {
|
||||||
if (it->second.flags & CSerialsCacheEntry::DIRTY) {
|
if (it->second.flags & CSerialsCacheEntry::DIRTY) {
|
||||||
BatchWriteSerial(batch, it->first, it->second.entered);
|
BatchWriteSerial(batch, it->first, it->second.entered);
|
||||||
// TODO: changed++?
|
// TODO: changed++?
|
||||||
}
|
}
|
||||||
CSerialsMap::iterator itOld = it++;
|
CNullifiersMap::iterator itOld = it++;
|
||||||
mapSerials.erase(itOld);
|
mapSerials.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashAnchor,
|
const uint256 &hashAnchor,
|
||||||
CAnchorsMap &mapAnchors,
|
CAnchorsMap &mapAnchors,
|
||||||
CSerialsMap &mapSerials);
|
CNullifiersMap &mapSerials);
|
||||||
bool GetStats(CCoinsStats &stats) const;
|
bool GetStats(CCoinsStats &stats) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user