diff --git a/src/coins.cpp b/src/coins.cpp index 9a056aadf..072d3f659 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -42,7 +42,7 @@ bool CCoins::Spend(uint32_t nPos) Cleanup(); return true; } -bool CCoinsView::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return false; } +bool CCoinsView::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return false; } bool CCoinsView::GetNullifier(const uint256 &nullifier, ShieldedType type) const { return false; } bool CCoinsView::GetCoins(const uint256 &txid, CCoins &coins) const { return false; } bool CCoinsView::HaveCoins(const uint256 &txid) const { return false; } @@ -59,7 +59,7 @@ bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; } CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { } -bool CCoinsViewBacked::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return base->GetAnchorAt(rt, tree); } +bool CCoinsViewBacked::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return base->GetSproutAnchorAt(rt, tree); } bool CCoinsViewBacked::GetNullifier(const uint256 &nullifier, ShieldedType type) const { return base->GetNullifier(nullifier, type); } bool CCoinsViewBacked::GetCoins(const uint256 &txid, CCoins &coins) const { return base->GetCoins(txid, coins); } bool CCoinsViewBacked::HaveCoins(const uint256 &txid) const { return base->HaveCoins(txid); } @@ -110,7 +110,7 @@ CCoinsMap::const_iterator CCoinsViewCache::FetchCoins(const uint256 &txid) const } -bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { +bool CCoinsViewCache::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { CAnchorsSproutMap::const_iterator it = cacheSproutAnchors.find(rt); if (it != cacheSproutAnchors.end()) { if (it->second.entered) { @@ -121,7 +121,7 @@ bool CCoinsViewCache::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tr } } - if (!base->GetAnchorAt(rt, tree)) { + if (!base->GetSproutAnchorAt(rt, tree)) { return false; } @@ -196,7 +196,7 @@ void CCoinsViewCache::PopAnchor(const uint256 &newrt) { // so that its tree exists in memory. { ZCIncrementalMerkleTree tree; - assert(GetAnchorAt(currentRoot, tree)); + assert(GetSproutAnchorAt(currentRoot, tree)); } // Mark the anchor as unentered, removing it from view @@ -441,7 +441,7 @@ bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const auto it = intermediates.find(joinsplit.anchor); if (it != intermediates.end()) { tree = it->second; - } else if (!GetAnchorAt(joinsplit.anchor, tree)) { + } else if (!GetSproutAnchorAt(joinsplit.anchor, tree)) { return false; } diff --git a/src/coins.h b/src/coins.h index aa408e78e..b774961e1 100644 --- a/src/coins.h +++ b/src/coins.h @@ -327,7 +327,7 @@ class CCoinsView { public: //! Retrieve the tree at a particular anchored root in the chain - virtual bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; + virtual bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; //! Determine whether a nullifier is spent or not virtual bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; @@ -370,7 +370,7 @@ protected: public: CCoinsViewBacked(CCoinsView *viewIn); - bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; + bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; bool HaveCoins(const uint256 &txid) const; @@ -436,7 +436,7 @@ public: ~CCoinsViewCache(); // Standard CCoinsView methods - bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; + bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; bool HaveCoins(const uint256 &txid) const; diff --git a/src/gtest/test_mempool.cpp b/src/gtest/test_mempool.cpp index 3061b4911..41aa5c832 100644 --- a/src/gtest/test_mempool.cpp +++ b/src/gtest/test_mempool.cpp @@ -19,7 +19,7 @@ class FakeCoinsViewDB : public CCoinsView { public: FakeCoinsViewDB() {} - bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { + bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return false; } diff --git a/src/gtest/test_validation.cpp b/src/gtest/test_validation.cpp index 84b107265..564767040 100644 --- a/src/gtest/test_validation.cpp +++ b/src/gtest/test_validation.cpp @@ -21,7 +21,7 @@ class FakeCoinsViewDB : public CCoinsView { public: FakeCoinsViewDB() {} - bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { + bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { return false; } diff --git a/src/main.cpp b/src/main.cpp index 9827c1438..21d4c3992 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2338,7 +2338,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin ZCIncrementalMerkleTree tree; // This should never fail: we should always be able to get the root // that is on the tip of our chain - assert(view.GetAnchorAt(old_tree_root, tree)); + assert(view.GetSproutAnchorAt(old_tree_root, tree)); { // Consistency check: the root of the tree we're given should @@ -2692,7 +2692,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { UpdateTip(pindexDelete->pprev); // Get the current commitment tree ZCIncrementalMerkleTree newTree; - assert(pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), newTree)); + assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(), newTree)); // Let wallets know transactions went from 1-confirmed to // 0-confirmed or conflicted: BOOST_FOREACH(const CTransaction &tx, block.vtx) { @@ -2726,7 +2726,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * } // Get the current commitment tree ZCIncrementalMerkleTree oldTree; - assert(pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), oldTree)); + assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(), oldTree)); // Apply the block atomically to the chain state. int64_t nTime2 = GetTimeMicros(); nTimeReadFromDisk += nTime2 - nTime1; int64_t nTime3; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8c5afbb6a..c4d33691d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -770,7 +770,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp) obj.push_back(Pair("pruned", fPruneMode)); ZCIncrementalMerkleTree tree; - pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), tree); + pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(), tree); obj.push_back(Pair("commitments", static_cast(tree.size()))); CBlockIndex* tip = chainActive.Tip(); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 39b9a09e8..bfe14b533 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -36,7 +36,7 @@ public: hashBestSproutAnchor_ = ZCIncrementalMerkleTree::empty_root(); } - bool GetAnchorAt(const uint256& rt, ZCIncrementalMerkleTree &tree) const { + bool GetSproutAnchorAt(const uint256& rt, ZCIncrementalMerkleTree &tree) const { if (rt == ZCIncrementalMerkleTree::empty_root()) { ZCIncrementalMerkleTree new_tree; tree = new_tree; @@ -339,7 +339,7 @@ BOOST_AUTO_TEST_CASE(anchor_pop_regression_test) // The base contains the anchor, of course! { ZCIncrementalMerkleTree checktree; - BOOST_CHECK(cache1.GetAnchorAt(tree.root(), checktree)); + BOOST_CHECK(cache1.GetSproutAnchorAt(tree.root(), checktree)); BOOST_CHECK(checktree.root() == tree.root()); } } @@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE(anchor_pop_regression_test) // treestate... { ZCIncrementalMerkleTree checktree; - BOOST_CHECK(cache1.GetAnchorAt(tree.root(), checktree)); + BOOST_CHECK(cache1.GetSproutAnchorAt(tree.root(), checktree)); BOOST_CHECK(checktree.root() == tree.root()); // Oh, shucks. } @@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE(anchor_pop_regression_test) cache1.Flush(); { ZCIncrementalMerkleTree checktree; - BOOST_CHECK(cache1.GetAnchorAt(tree.root(), checktree)); + BOOST_CHECK(cache1.GetSproutAnchorAt(tree.root(), checktree)); BOOST_CHECK(checktree.root() == tree.root()); // Oh, shucks. } } @@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE(anchor_regression_test) cache1.PopAnchor(ZCIncrementalMerkleTree::empty_root()); BOOST_CHECK(cache1.GetBestAnchor() == ZCIncrementalMerkleTree::empty_root()); - BOOST_CHECK(!cache1.GetAnchorAt(tree.root(), tree)); + BOOST_CHECK(!cache1.GetSproutAnchorAt(tree.root(), tree)); } // Also correct behavior: @@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE(anchor_regression_test) cache1.PopAnchor(ZCIncrementalMerkleTree::empty_root()); cache1.Flush(); BOOST_CHECK(cache1.GetBestAnchor() == ZCIncrementalMerkleTree::empty_root()); - BOOST_CHECK(!cache1.GetAnchorAt(tree.root(), tree)); + BOOST_CHECK(!cache1.GetSproutAnchorAt(tree.root(), tree)); } // Works because we bring the anchor in from parent cache. @@ -439,13 +439,13 @@ BOOST_AUTO_TEST_CASE(anchor_regression_test) { // Pop anchor. CCoinsViewCacheTest cache2(&cache1); - BOOST_CHECK(cache2.GetAnchorAt(tree.root(), tree)); + BOOST_CHECK(cache2.GetSproutAnchorAt(tree.root(), tree)); cache2.PopAnchor(ZCIncrementalMerkleTree::empty_root()); cache2.Flush(); } BOOST_CHECK(cache1.GetBestAnchor() == ZCIncrementalMerkleTree::empty_root()); - BOOST_CHECK(!cache1.GetAnchorAt(tree.root(), tree)); + BOOST_CHECK(!cache1.GetSproutAnchorAt(tree.root(), tree)); } // Was broken: @@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(anchor_regression_test) } BOOST_CHECK(cache1.GetBestAnchor() == ZCIncrementalMerkleTree::empty_root()); - BOOST_CHECK(!cache1.GetAnchorAt(tree.root(), tree)); + BOOST_CHECK(!cache1.GetSproutAnchorAt(tree.root(), tree)); } } @@ -502,7 +502,7 @@ BOOST_AUTO_TEST_CASE(anchors_flush_test) { CCoinsViewCacheTest cache(&base); ZCIncrementalMerkleTree tree; - BOOST_CHECK(cache.GetAnchorAt(cache.GetBestAnchor(), tree)); + BOOST_CHECK(cache.GetSproutAnchorAt(cache.GetBestAnchor(), tree)); appendRandomCommitment(tree); newrt = tree.root(); @@ -514,10 +514,10 @@ BOOST_AUTO_TEST_CASE(anchors_flush_test) { CCoinsViewCacheTest cache(&base); ZCIncrementalMerkleTree tree; - BOOST_CHECK(cache.GetAnchorAt(cache.GetBestAnchor(), tree)); + BOOST_CHECK(cache.GetSproutAnchorAt(cache.GetBestAnchor(), tree)); // Get the cached entry. - BOOST_CHECK(cache.GetAnchorAt(cache.GetBestAnchor(), tree)); + BOOST_CHECK(cache.GetSproutAnchorAt(cache.GetBestAnchor(), tree)); uint256 check_rt = tree.root(); @@ -615,7 +615,7 @@ BOOST_AUTO_TEST_CASE(anchors_test) { ZCIncrementalMerkleTree tree; - BOOST_CHECK(cache.GetAnchorAt(cache.GetBestAnchor(), tree)); + BOOST_CHECK(cache.GetSproutAnchorAt(cache.GetBestAnchor(), tree)); BOOST_CHECK(cache.GetBestAnchor() == tree.root()); appendRandomCommitment(tree); appendRandomCommitment(tree); @@ -636,7 +636,7 @@ BOOST_AUTO_TEST_CASE(anchors_test) { ZCIncrementalMerkleTree confirm_same; - BOOST_CHECK(cache.GetAnchorAt(cache.GetBestAnchor(), confirm_same)); + BOOST_CHECK(cache.GetSproutAnchorAt(cache.GetBestAnchor(), confirm_same)); BOOST_CHECK(confirm_same.root() == newrt); } @@ -650,13 +650,13 @@ BOOST_AUTO_TEST_CASE(anchors_test) BOOST_CHECK(cache.GetBestAnchor() == newrt2); ZCIncrementalMerkleTree test_tree; - BOOST_CHECK(cache.GetAnchorAt(cache.GetBestAnchor(), test_tree)); + BOOST_CHECK(cache.GetSproutAnchorAt(cache.GetBestAnchor(), test_tree)); BOOST_CHECK(tree.root() == test_tree.root()); { ZCIncrementalMerkleTree test_tree2; - cache.GetAnchorAt(newrt, test_tree2); + cache.GetSproutAnchorAt(newrt, test_tree2); BOOST_CHECK(test_tree2.root() == newrt); } @@ -664,8 +664,8 @@ BOOST_AUTO_TEST_CASE(anchors_test) { cache.PopAnchor(newrt); ZCIncrementalMerkleTree obtain_tree; - assert(!cache.GetAnchorAt(newrt2, obtain_tree)); // should have been popped off - assert(cache.GetAnchorAt(newrt, obtain_tree)); + assert(!cache.GetSproutAnchorAt(newrt2, obtain_tree)); // should have been popped off + assert(cache.GetSproutAnchorAt(newrt, obtain_tree)); assert(obtain_tree.root() == newrt); } diff --git a/src/txdb.cpp b/src/txdb.cpp index 9b36192a4..8d07d59ba 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -40,7 +40,7 @@ CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(Get } -bool CCoinsViewDB::GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { +bool CCoinsViewDB::GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const { if (rt == ZCIncrementalMerkleTree::empty_root()) { ZCIncrementalMerkleTree new_tree; tree = new_tree; diff --git a/src/txdb.h b/src/txdb.h index 75e60d8b0..3290be28c 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -35,7 +35,7 @@ protected: public: CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); - bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; + bool GetSproutAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; bool GetNullifier(const uint256 &nf, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; bool HaveCoins(const uint256 &txid) const; diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 6fde29f40..a7fc3d1f7 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -402,7 +402,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const if (it != intermediates.end()) { tree = it->second; } else { - assert(pcoins->GetAnchorAt(joinsplit.anchor, tree)); + assert(pcoins->GetSproutAnchorAt(joinsplit.anchor, tree)); } BOOST_FOREACH(const uint256& commitment, joinsplit.commitments) diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index cae42019a..abc9d1338 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -429,7 +429,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() auto it = intermediates.find(prevJoinSplit.anchor); if (it != intermediates.end()) { tree = it->second; - } else if (!pcoinsTip->GetAnchorAt(prevJoinSplit.anchor, tree)) { + } else if (!pcoinsTip->GetSproutAnchorAt(prevJoinSplit.anchor, tree)) { throw JSONRPCError(RPC_WALLET_ERROR, "Could not find previous JoinSplit anchor"); } diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 73a9360d7..dae33d3f3 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -545,7 +545,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { auto it = intermediates.find(prevJoinSplit.anchor); if (it != intermediates.end()) { tree = it->second; - } else if (!pcoinsTip->GetAnchorAt(prevJoinSplit.anchor, tree)) { + } else if (!pcoinsTip->GetSproutAnchorAt(prevJoinSplit.anchor, tree)) { throw JSONRPCError(RPC_WALLET_ERROR, "Could not find previous JoinSplit anchor"); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1a1e1959c..0a66f1e36 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1765,7 +1765,7 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, // Consistency check: we should be able to find the current tree // in our CCoins view. ZCIncrementalMerkleTree dummy_tree; - assert(pcoinsTip->GetAnchorAt(current_anchor, dummy_tree)); + assert(pcoinsTip->GetSproutAnchorAt(current_anchor, dummy_tree)); pindex = chainActive.Next(pindex); } @@ -1819,7 +1819,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) ZCIncrementalMerkleTree tree; // This should never fail: we should always be able to get the tree // state on the path to the tip of our chain - assert(pcoinsTip->GetAnchorAt(pindex->hashSproutAnchor, tree)); + assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, tree)); // Increment note witness caches IncrementNoteWitnesses(pindex, &block, tree);