]> Git Repo - VerusCoin.git/commitdiff
Specifically describe anchors as Sprout anchors.
authorSean Bowe <[email protected]>
Thu, 26 Apr 2018 00:38:34 +0000 (18:38 -0600)
committerSean Bowe <[email protected]>
Mon, 7 May 2018 19:46:06 +0000 (13:46 -0600)
src/coins.cpp
src/coins.h
src/gtest/test_mempool.cpp
src/gtest/test_validation.cpp
src/test/coins_tests.cpp
src/txdb.cpp
src/txdb.h
src/zcbenchmarks.cpp

index 87b00a226fb6339f803457cc35d81a712015d1ef..b31703a7dbf86f8086849402007b57b71664d5a2 100644 (file)
@@ -51,7 +51,7 @@ uint256 CCoinsView::GetBestAnchor() const { return uint256(); };
 bool CCoinsView::BatchWrite(CCoinsMap &mapCoins,
                             const uint256 &hashBlock,
                             const uint256 &hashAnchor,
-                            CAnchorsMap &mapAnchors,
+                            CAnchorsSproutMap &mapSproutAnchors,
                             CNullifiersMap &mapSproutNullifiers,
                             CNullifiersMap &mapSaplingNullifiers) { 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,
                                   const uint256 &hashBlock,
                                   const uint256 &hashAnchor,
-                                  CAnchorsMap &mapAnchors,
+                                  CAnchorsSproutMap &mapSproutAnchors,
                                   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); }
 
 CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {}
@@ -85,7 +85,7 @@ CCoinsViewCache::~CCoinsViewCache()
 
 size_t CCoinsViewCache::DynamicMemoryUsage() const {
     return memusage::DynamicUsage(cacheCoins) +
-           memusage::DynamicUsage(cacheAnchors) +
+           memusage::DynamicUsage(cacheSproutAnchors) +
            memusage::DynamicUsage(cacheSproutNullifiers) +
            memusage::DynamicUsage(cacheSaplingNullifiers) +
            cachedCoinsUsage;
@@ -111,8 +111,8 @@ CCoinsMap::const_iterator CCoinsViewCache::FetchCoins(const uint256 &txid) const
 
 
 bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const {
-    CAnchorsMap::const_iterator it = cacheAnchors.find(rt);
-    if (it != cacheAnchors.end()) {
+    CAnchorsSproutMap::const_iterator it = cacheSproutAnchors.find(rt);
+    if (it != cacheSproutAnchors.end()) {
         if (it->second.entered) {
             tree = it->second.tree;
             return true;
@@ -125,7 +125,7 @@ bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tr
         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.tree = tree;
     cachedCoinsUsage += ret->second.tree.DynamicMemoryUsage();
@@ -164,17 +164,17 @@ void CCoinsViewCache::PushAnchor(const ZCIncrementalMerkleTree &tree) {
     auto currentRoot = GetBestAnchor();
 
     // 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
-    // different way (make all blocks modify mapAnchors somehow)
+    // different way (make all blocks modify mapSproutAnchors somehow)
     // but this is simpler to reason about.
     if (currentRoot != newrt) {
-        auto insertRet = cacheAnchors.insert(std::make_pair(newrt, CAnchorsCacheEntry()));
-        CAnchorsMap::iterator ret = insertRet.first;
+        auto insertRet = cacheSproutAnchors.insert(std::make_pair(newrt, CAnchorsSproutCacheEntry()));
+        CAnchorsSproutMap::iterator ret = insertRet.first;
 
         ret->second.entered = true;
         ret->second.tree = tree;
-        ret->second.flags = CAnchorsCacheEntry::DIRTY;
+        ret->second.flags = CAnchorsSproutCacheEntry::DIRTY;
 
         if (insertRet.second) {
             // An insert took place
@@ -200,10 +200,10 @@ void CCoinsViewCache::PopAnchor(const uint256 &newrt) {
         }
 
         // 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
-        cacheAnchors[currentRoot].flags = CAnchorsCacheEntry::DIRTY;
+        cacheSproutAnchors[currentRoot].flags = CAnchorsSproutCacheEntry::DIRTY;
 
         // Mark the new root as the best anchor
         hashAnchor = newrt;
@@ -315,7 +315,7 @@ void BatchWriteNullifiers(CNullifiersMap &mapNullifiers, CNullifiersMap &cacheNu
 bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
                                  const uint256 &hashBlockIn,
                                  const uint256 &hashAnchorIn,
-                                 CAnchorsMap &mapAnchors,
+                                 CAnchorsSproutMap &mapSproutAnchors,
                                  CNullifiersMap &mapSproutNullifiers,
                                  CNullifiersMap &mapSaplingNullifiers) {
     assert(!hasModifier);
@@ -354,29 +354,29 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
         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) {
-            CAnchorsMap::iterator parent_it = cacheAnchors.find(child_it->first);
+        if (child_it->second.flags & CAnchorsSproutCacheEntry::DIRTY) {
+            CAnchorsSproutMap::iterator parent_it = cacheSproutAnchors.find(child_it->first);
 
-            if (parent_it == cacheAnchors.end()) {
-                CAnchorsCacheEntry& entry = cacheAnchors[child_it->first];
+            if (parent_it == cacheSproutAnchors.end()) {
+                CAnchorsSproutCacheEntry& entry = cacheSproutAnchors[child_it->first];
                 entry.entered = child_it->second.entered;
                 entry.tree = child_it->second.tree;
-                entry.flags = CAnchorsCacheEntry::DIRTY;
+                entry.flags = CAnchorsSproutCacheEntry::DIRTY;
 
                 cachedCoinsUsage += entry.tree.DynamicMemoryUsage();
             } else {
                 if (parent_it->second.entered != child_it->second.entered) {
                     // The parent may have removed the entry.
                     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++;
-        mapAnchors.erase(itOld);
+        CAnchorsSproutMap::iterator itOld = child_it++;
+        mapSproutAnchors.erase(itOld);
     }
 
     ::BatchWriteNullifiers(mapSproutNullifiers, cacheSproutNullifiers);
@@ -388,9 +388,9 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
 }
 
 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();
-    cacheAnchors.clear();
+    cacheSproutAnchors.clear();
     cacheSproutNullifiers.clear();
     cacheSaplingNullifiers.clear();
     cachedCoinsUsage = 0;
index a796c9bfb87976ce6905dec4db054d3e93e5ef35..60c6963d31c56ae605d58c8499c7d903de8db856 100644 (file)
@@ -273,7 +273,7 @@ struct CCoinsCacheEntry
     CCoinsCacheEntry() : coins(), flags(0) {}
 };
 
-struct CAnchorsCacheEntry
+struct CAnchorsSproutCacheEntry
 {
     bool entered; // This will be false if the anchor is removed from the cache
     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.
     };
 
-    CAnchorsCacheEntry() : entered(false), flags(0) {}
+    CAnchorsSproutCacheEntry() : entered(false), flags(0) {}
 };
 
 struct CNullifiersCacheEntry
@@ -305,7 +305,7 @@ enum ShieldedType
 };
 
 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;
 
 struct CCoinsStats
@@ -350,7 +350,7 @@ public:
     virtual bool BatchWrite(CCoinsMap &mapCoins,
                             const uint256 &hashBlock,
                             const uint256 &hashAnchor,
-                            CAnchorsMap &mapAnchors,
+                            CAnchorsSproutMap &mapSproutAnchors,
                             CNullifiersMap &mapSproutNullifiers,
                             CNullifiersMap &mapSaplingNullifiers);
 
@@ -380,7 +380,7 @@ public:
     bool BatchWrite(CCoinsMap &mapCoins,
                     const uint256 &hashBlock,
                     const uint256 &hashAnchor,
-                    CAnchorsMap &mapAnchors,
+                    CAnchorsSproutMap &mapSproutAnchors,
                     CNullifiersMap &mapSproutNullifiers,
                     CNullifiersMap &mapSaplingNullifiers);
     bool GetStats(CCoinsStats &stats) const;
@@ -424,7 +424,7 @@ protected:
     mutable uint256 hashBlock;
     mutable CCoinsMap cacheCoins;
     mutable uint256 hashAnchor;
-    mutable CAnchorsMap cacheAnchors;
+    mutable CAnchorsSproutMap cacheSproutAnchors;
     mutable CNullifiersMap cacheSproutNullifiers;
     mutable CNullifiersMap cacheSaplingNullifiers;
 
@@ -446,7 +446,7 @@ public:
     bool BatchWrite(CCoinsMap &mapCoins,
                     const uint256 &hashBlock,
                     const uint256 &hashAnchor,
-                    CAnchorsMap &mapAnchors,
+                    CAnchorsSproutMap &mapSproutAnchors,
                     CNullifiersMap &mapSproutNullifiers,
                     CNullifiersMap &mapSaplingNullifiers);
 
index 2a74ea9b327e923676cd939ecb4d3d411fe3f15a..b64683563f207c95e927ec8dbf2af9230318db4b 100644 (file)
@@ -55,7 +55,7 @@ public:
     bool BatchWrite(CCoinsMap &mapCoins,
                     const uint256 &hashBlock,
                     const uint256 &hashAnchor,
-                    CAnchorsMap &mapAnchors,
+                    CAnchorsSproutMap &mapSproutAnchors,
                     CNullifiersMap &mapSproutNullifiers,
                     CNullifiersMap &mapSaplingNullifiers) {
         return false;
index cabeeb3a792028f5b72337c7a2461894da5570a7..c4abba2bba4ba63457ec08f8bedcf30351093554 100644 (file)
@@ -50,7 +50,7 @@ public:
     bool BatchWrite(CCoinsMap &mapCoins,
                     const uint256 &hashBlock,
                     const uint256 &hashAnchor,
-                    CAnchorsMap &mapAnchors,
+                    CAnchorsSproutMap &mapSproutAnchors,
                     CNullifiersMap &mapSproutNullifiers,
                     CNullifiersMap saplingNullifiersMap) {
         return false;
index 2767112e60ad583dbac0178eda9e87a8cfe76914..94d11a68ed52c9fa1bcf97d0cc0c84a01857bc83 100644 (file)
@@ -27,7 +27,7 @@ class CCoinsViewTest : public CCoinsView
     uint256 hashBestBlock_;
     uint256 hashBestAnchor_;
     std::map<uint256, CCoins> map_;
-    std::map<uint256, ZCIncrementalMerkleTree> mapAnchors_;
+    std::map<uint256, ZCIncrementalMerkleTree> mapSproutAnchors_;
     std::map<uint256, bool> mapSproutNullifiers_;
     std::map<uint256, bool> mapSaplingNullifiers_;
 
@@ -43,8 +43,8 @@ public:
             return true;
         }
 
-        std::map<uint256, ZCIncrementalMerkleTree>::const_iterator it = mapAnchors_.find(rt);
-        if (it == mapAnchors_.end()) {
+        std::map<uint256, ZCIncrementalMerkleTree>::const_iterator it = mapSproutAnchors_.find(rt);
+        if (it == mapSproutAnchors_.end()) {
             return false;
         } else {
             tree = it->second;
@@ -115,7 +115,7 @@ public:
     bool BatchWrite(CCoinsMap& mapCoins,
                     const uint256& hashBlock,
                     const uint256& hashAnchor,
-                    CAnchorsMap& mapAnchors,
+                    CAnchorsSproutMap& mapSproutAnchors,
                     CNullifiersMap& mapSproutNullifiers,
                     CNullifiersMap& mapSaplingNullifiers)
     {
@@ -127,23 +127,23 @@ public:
             }
             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) {
                 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;
             } else {
-                mapAnchors_.erase(it->first);
+                mapSproutAnchors_.erase(it->first);
             }
-            mapAnchors.erase(it++);
+            mapSproutAnchors.erase(it++);
         }
 
         BatchWriteNullifiers(mapSproutNullifiers, mapSproutNullifiers_);
         BatchWriteNullifiers(mapSaplingNullifiers, mapSaplingNullifiers_);
 
         mapCoins.clear();
-        mapAnchors.clear();
+        mapSproutAnchors.clear();
         hashBestBlock_ = hashBlock;
         hashBestAnchor_ = hashAnchor;
         return true;
@@ -161,7 +161,7 @@ public:
     {
         // Manually recompute the dynamic usage of the whole data, and compare it.
         size_t ret = memusage::DynamicUsage(cacheCoins) +
-                     memusage::DynamicUsage(cacheAnchors) +
+                     memusage::DynamicUsage(cacheSproutAnchors) +
                      memusage::DynamicUsage(cacheSproutNullifiers) +
                      memusage::DynamicUsage(cacheSaplingNullifiers);
         for (CCoinsMap::iterator it = cacheCoins.begin(); it != cacheCoins.end(); it++) {
index eb3617fc62c6f09046f66b914cc2a0a87c939081..f2a27beee03f3ae3ace32e03dbcabeadbcb00d39 100644 (file)
@@ -108,7 +108,7 @@ void BatchWriteNullifiers(CDBBatch& batch, CNullifiersMap& mapToUse, const char&
 bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
                               const uint256 &hashBlock,
                               const uint256 &hashAnchor,
-                              CAnchorsMap &mapAnchors,
+                              CAnchorsSproutMap &mapSproutAnchors,
                               CNullifiersMap &mapSproutNullifiers,
                               CNullifiersMap &mapSaplingNullifiers) {
     CDBBatch batch(db);
@@ -127,8 +127,8 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
         mapCoins.erase(itOld);
     }
 
-    for (CAnchorsMap::iterator it = mapAnchors.begin(); it != mapAnchors.end();) {
-        if (it->second.flags & CAnchorsCacheEntry::DIRTY) {
+    for (CAnchorsSproutMap::iterator it = mapSproutAnchors.begin(); it != mapSproutAnchors.end();) {
+        if (it->second.flags & CAnchorsSproutCacheEntry::DIRTY) {
             if (!it->second.entered)
                 batch.Erase(make_pair(DB_ANCHOR, it->first));
             else {
@@ -136,8 +136,8 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
             }
             // TODO: changed++?
         }
-        CAnchorsMap::iterator itOld = it++;
-        mapAnchors.erase(itOld);
+        CAnchorsSproutMap::iterator itOld = it++;
+        mapSproutAnchors.erase(itOld);
     }
 
     ::BatchWriteNullifiers(batch, mapSproutNullifiers, DB_NULLIFIER);
index 99ff4f31f0d425781475c1460c40ca505492742c..b2a4f4c28aa6da8a8a336d04b2dd78ada3642a08 100644 (file)
@@ -44,7 +44,7 @@ public:
     bool BatchWrite(CCoinsMap &mapCoins,
                     const uint256 &hashBlock,
                     const uint256 &hashAnchor,
-                    CAnchorsMap &mapAnchors,
+                    CAnchorsSproutMap &mapSproutAnchors,
                     CNullifiersMap &mapSproutNullifiers,
                     CNullifiersMap &mapSaplingNullifiers);
     bool GetStats(CCoinsStats &stats) const;
index 1567ad01e0fefc3f24b6f7bcb117547137cbedca..80c726b5a297d910d3eb7ad1ccfa51aef23bd86d 100644 (file)
@@ -381,7 +381,7 @@ public:
     bool BatchWrite(CCoinsMap &mapCoins,
                     const uint256 &hashBlock,
                     const uint256 &hashAnchor,
-                    CAnchorsMap &mapAnchors,
+                    CAnchorsSproutMap &mapSproutAnchors,
                     CNullifiersMap &mapSproutNullifiers,
                     CNullifiersMap& mapSaplingNullifiers) {
         return false;
This page took 0.046185 seconds and 4 git commands to generate.