Rename hashAnchor to hashSproutAnchor.
This commit is contained in:
10
src/chain.h
10
src/chain.h
@@ -152,10 +152,10 @@ public:
|
||||
boost::optional<uint32_t> nCachedBranchId;
|
||||
|
||||
//! The anchor for the tree state up to the start of this block
|
||||
uint256 hashAnchor;
|
||||
uint256 hashSproutAnchor;
|
||||
|
||||
//! (memory only) The anchor for the tree state up to the end of this block
|
||||
uint256 hashAnchorEnd;
|
||||
uint256 hashSproutAnchorEnd;
|
||||
|
||||
//! Change in value held by the Sprout circuit over this block.
|
||||
//! Will be boost::none for older blocks on old nodes until a reindex has taken place.
|
||||
@@ -192,8 +192,8 @@ public:
|
||||
nChainTx = 0;
|
||||
nStatus = 0;
|
||||
nCachedBranchId = boost::none;
|
||||
hashAnchor = uint256();
|
||||
hashAnchorEnd = uint256();
|
||||
hashSproutAnchor = uint256();
|
||||
hashSproutAnchorEnd = uint256();
|
||||
nSequenceId = 0;
|
||||
nSproutValue = boost::none;
|
||||
nChainSproutValue = boost::none;
|
||||
@@ -366,7 +366,7 @@ public:
|
||||
READWRITE(branchId);
|
||||
}
|
||||
}
|
||||
READWRITE(hashAnchor);
|
||||
READWRITE(hashSproutAnchor);
|
||||
|
||||
// block header
|
||||
READWRITE(this->nVersion);
|
||||
|
||||
@@ -50,7 +50,7 @@ uint256 CCoinsView::GetBestBlock() const { return uint256(); }
|
||||
uint256 CCoinsView::GetBestAnchor() const { return uint256(); };
|
||||
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers) { return false; }
|
||||
@@ -68,10 +68,10 @@ uint256 CCoinsViewBacked::GetBestAnchor() const { return base->GetBestAnchor();
|
||||
void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; }
|
||||
bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers) { return base->BatchWrite(mapCoins, hashBlock, hashAnchor, mapSproutAnchors, mapSproutNullifiers, mapSaplingNullifiers); }
|
||||
CNullifiersMap &mapSaplingNullifiers) { return base->BatchWrite(mapCoins, hashBlock, hashSproutAnchor, mapSproutAnchors, mapSproutNullifiers, mapSaplingNullifiers); }
|
||||
bool CCoinsViewBacked::GetStats(CCoinsStats &stats) const { return base->GetStats(stats); }
|
||||
|
||||
CCoinsKeyHasher::CCoinsKeyHasher() : salt(GetRandHash()) {}
|
||||
@@ -181,7 +181,7 @@ void CCoinsViewCache::PushAnchor(const ZCIncrementalMerkleTree &tree) {
|
||||
cachedCoinsUsage += ret->second.tree.DynamicMemoryUsage();
|
||||
}
|
||||
|
||||
hashAnchor = newrt;
|
||||
hashSproutAnchor = newrt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ void CCoinsViewCache::PopAnchor(const uint256 &newrt) {
|
||||
cacheSproutAnchors[currentRoot].flags = CAnchorsSproutCacheEntry::DIRTY;
|
||||
|
||||
// Mark the new root as the best anchor
|
||||
hashAnchor = newrt;
|
||||
hashSproutAnchor = newrt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,9 +281,9 @@ uint256 CCoinsViewCache::GetBestBlock() const {
|
||||
|
||||
|
||||
uint256 CCoinsViewCache::GetBestAnchor() const {
|
||||
if (hashAnchor.IsNull())
|
||||
hashAnchor = base->GetBestAnchor();
|
||||
return hashAnchor;
|
||||
if (hashSproutAnchor.IsNull())
|
||||
hashSproutAnchor = base->GetBestAnchor();
|
||||
return hashSproutAnchor;
|
||||
}
|
||||
|
||||
void CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
|
||||
@@ -314,7 +314,7 @@ void BatchWriteNullifiers(CNullifiersMap &mapNullifiers, CNullifiersMap &cacheNu
|
||||
|
||||
bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlockIn,
|
||||
const uint256 &hashAnchorIn,
|
||||
const uint256 &hashSproutAnchorIn,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers) {
|
||||
@@ -382,13 +382,13 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
||||
::BatchWriteNullifiers(mapSproutNullifiers, cacheSproutNullifiers);
|
||||
::BatchWriteNullifiers(mapSaplingNullifiers, cacheSaplingNullifiers);
|
||||
|
||||
hashAnchor = hashAnchorIn;
|
||||
hashSproutAnchor = hashSproutAnchorIn;
|
||||
hashBlock = hashBlockIn;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCoinsViewCache::Flush() {
|
||||
bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashAnchor, cacheSproutAnchors, cacheSproutNullifiers, cacheSaplingNullifiers);
|
||||
bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashSproutAnchor, cacheSproutAnchors, cacheSproutNullifiers, cacheSaplingNullifiers);
|
||||
cacheCoins.clear();
|
||||
cacheSproutAnchors.clear();
|
||||
cacheSproutNullifiers.clear();
|
||||
|
||||
@@ -349,7 +349,7 @@ public:
|
||||
//! The passed mapCoins can be modified.
|
||||
virtual bool BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers);
|
||||
@@ -379,7 +379,7 @@ public:
|
||||
void SetBackend(CCoinsView &viewIn);
|
||||
bool BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers);
|
||||
@@ -423,7 +423,7 @@ protected:
|
||||
*/
|
||||
mutable uint256 hashBlock;
|
||||
mutable CCoinsMap cacheCoins;
|
||||
mutable uint256 hashAnchor;
|
||||
mutable uint256 hashSproutAnchor;
|
||||
mutable CAnchorsSproutMap cacheSproutAnchors;
|
||||
mutable CNullifiersMap cacheSproutNullifiers;
|
||||
mutable CNullifiersMap cacheSaplingNullifiers;
|
||||
@@ -445,7 +445,7 @@ public:
|
||||
void SetBestBlock(const uint256 &hashBlock);
|
||||
bool BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers);
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
bool BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
bool BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap saplingNullifiersMap) {
|
||||
|
||||
16
src/main.cpp
16
src/main.cpp
@@ -2295,9 +2295,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
view.SetBestBlock(pindex->GetBlockHash());
|
||||
// Before the genesis block, there was an empty tree
|
||||
ZCIncrementalMerkleTree tree;
|
||||
pindex->hashAnchor = tree.root();
|
||||
pindex->hashSproutAnchor = tree.root();
|
||||
// The genesis block contained no JoinSplits
|
||||
pindex->hashAnchorEnd = pindex->hashAnchor;
|
||||
pindex->hashSproutAnchorEnd = pindex->hashSproutAnchor;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2333,7 +2333,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
auto old_tree_root = view.GetBestAnchor();
|
||||
// saving the top anchor in the block index as we go.
|
||||
if (!fJustCheck) {
|
||||
pindex->hashAnchor = old_tree_root;
|
||||
pindex->hashSproutAnchor = old_tree_root;
|
||||
}
|
||||
ZCIncrementalMerkleTree tree;
|
||||
// This should never fail: we should always be able to get the root
|
||||
@@ -2413,7 +2413,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
|
||||
view.PushAnchor(tree);
|
||||
if (!fJustCheck) {
|
||||
pindex->hashAnchorEnd = tree.root();
|
||||
pindex->hashSproutAnchorEnd = tree.root();
|
||||
}
|
||||
blockundo.old_tree_root = old_tree_root;
|
||||
|
||||
@@ -3927,12 +3927,12 @@ bool static LoadBlockIndexDB()
|
||||
{
|
||||
CBlockIndex* pindex = item.second;
|
||||
// - This relationship will always be true even if pprev has multiple
|
||||
// children, because hashAnchor is technically a property of pprev,
|
||||
// children, because hashSproutAnchor is technically a property of pprev,
|
||||
// not its children.
|
||||
// - This will miss chain tips; we handle the best tip below, and other
|
||||
// tips will be handled by ConnectTip during a re-org.
|
||||
if (pindex->pprev) {
|
||||
pindex->pprev->hashAnchorEnd = pindex->hashAnchor;
|
||||
pindex->pprev->hashSproutAnchorEnd = pindex->hashSproutAnchor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3941,8 +3941,8 @@ bool static LoadBlockIndexDB()
|
||||
if (it == mapBlockIndex.end())
|
||||
return true;
|
||||
chainActive.SetTip(it->second);
|
||||
// Set hashAnchorEnd for the end of best chain
|
||||
it->second->hashAnchorEnd = pcoinsTip->GetBestAnchor();
|
||||
// Set hashSproutAnchorEnd for the end of best chain
|
||||
it->second->hashSproutAnchorEnd = pcoinsTip->GetBestAnchor();
|
||||
|
||||
PruneBlockIndexCandidates();
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
|
||||
result.push_back(Pair("bits", strprintf("%08x", block.nBits)));
|
||||
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
|
||||
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
|
||||
result.push_back(Pair("anchor", blockindex->hashAnchorEnd.GetHex()));
|
||||
result.push_back(Pair("anchor", blockindex->hashSproutAnchorEnd.GetHex()));
|
||||
|
||||
UniValue valuePools(UniValue::VARR);
|
||||
valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue));
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace
|
||||
class CCoinsViewTest : public CCoinsView
|
||||
{
|
||||
uint256 hashBestBlock_;
|
||||
uint256 hashBestAnchor_;
|
||||
uint256 hashBestSproutAnchor_;
|
||||
std::map<uint256, CCoins> map_;
|
||||
std::map<uint256, ZCIncrementalMerkleTree> mapSproutAnchors_;
|
||||
std::map<uint256, bool> mapSproutNullifiers_;
|
||||
@@ -33,7 +33,7 @@ class CCoinsViewTest : public CCoinsView
|
||||
|
||||
public:
|
||||
CCoinsViewTest() {
|
||||
hashBestAnchor_ = ZCIncrementalMerkleTree::empty_root();
|
||||
hashBestSproutAnchor_ = ZCIncrementalMerkleTree::empty_root();
|
||||
}
|
||||
|
||||
bool GetAnchorAt(const uint256& rt, ZCIncrementalMerkleTree &tree) const {
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
uint256 GetBestAnchor() const { return hashBestAnchor_; }
|
||||
uint256 GetBestAnchor() const { return hashBestSproutAnchor_; }
|
||||
|
||||
bool GetCoins(const uint256& txid, CCoins& coins) const
|
||||
{
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
|
||||
bool BatchWrite(CCoinsMap& mapCoins,
|
||||
const uint256& hashBlock,
|
||||
const uint256& hashAnchor,
|
||||
const uint256& hashSproutAnchor,
|
||||
CAnchorsSproutMap& mapSproutAnchors,
|
||||
CNullifiersMap& mapSproutNullifiers,
|
||||
CNullifiersMap& mapSaplingNullifiers)
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
mapCoins.clear();
|
||||
mapSproutAnchors.clear();
|
||||
hashBestBlock_ = hashBlock;
|
||||
hashBestAnchor_ = hashAnchor;
|
||||
hashBestSproutAnchor_ = hashSproutAnchor;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
12
src/txdb.cpp
12
src/txdb.cpp
@@ -26,7 +26,7 @@ static const char DB_TXINDEX = 't';
|
||||
static const char DB_BLOCK_INDEX = 'b';
|
||||
|
||||
static const char DB_BEST_BLOCK = 'B';
|
||||
static const char DB_BEST_ANCHOR = 'a';
|
||||
static const char DB_BEST_SPROUT_ANCHOR = 'a';
|
||||
static const char DB_FLAG = 'F';
|
||||
static const char DB_REINDEX_FLAG = 'R';
|
||||
static const char DB_LAST_BLOCK = 'l';
|
||||
@@ -85,7 +85,7 @@ uint256 CCoinsViewDB::GetBestBlock() const {
|
||||
|
||||
uint256 CCoinsViewDB::GetBestAnchor() const {
|
||||
uint256 hashBestAnchor;
|
||||
if (!db.Read(DB_BEST_ANCHOR, hashBestAnchor))
|
||||
if (!db.Read(DB_BEST_SPROUT_ANCHOR, hashBestAnchor))
|
||||
return ZCIncrementalMerkleTree::empty_root();
|
||||
return hashBestAnchor;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ void BatchWriteNullifiers(CDBBatch& batch, CNullifiersMap& mapToUse, const char&
|
||||
|
||||
bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers) {
|
||||
@@ -145,8 +145,8 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins,
|
||||
|
||||
if (!hashBlock.IsNull())
|
||||
batch.Write(DB_BEST_BLOCK, hashBlock);
|
||||
if (!hashAnchor.IsNull())
|
||||
batch.Write(DB_BEST_ANCHOR, hashAnchor);
|
||||
if (!hashSproutAnchor.IsNull())
|
||||
batch.Write(DB_BEST_SPROUT_ANCHOR, hashSproutAnchor);
|
||||
|
||||
LogPrint("coindb", "Committing %u changed transactions (out of %u) to coin database...\n", (unsigned int)changed, (unsigned int)count);
|
||||
return db.WriteBatch(batch);
|
||||
@@ -284,7 +284,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
||||
pindexNew->nFile = diskindex.nFile;
|
||||
pindexNew->nDataPos = diskindex.nDataPos;
|
||||
pindexNew->nUndoPos = diskindex.nUndoPos;
|
||||
pindexNew->hashAnchor = diskindex.hashAnchor;
|
||||
pindexNew->hashSproutAnchor = diskindex.hashSproutAnchor;
|
||||
pindexNew->nVersion = diskindex.nVersion;
|
||||
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
|
||||
pindexNew->hashReserved = diskindex.hashReserved;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
uint256 GetBestAnchor() const;
|
||||
bool BatchWrite(CCoinsMap &mapCoins,
|
||||
const uint256 &hashBlock,
|
||||
const uint256 &hashAnchor,
|
||||
const uint256 &hashSproutAnchor,
|
||||
CAnchorsSproutMap &mapSproutAnchors,
|
||||
CNullifiersMap &mapSproutNullifiers,
|
||||
CNullifiersMap &mapSaplingNullifiers);
|
||||
|
||||
@@ -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->hashAnchor, tree));
|
||||
assert(pcoinsTip->GetAnchorAt(pindex->hashSproutAnchor, tree));
|
||||
// Increment note witness caches
|
||||
IncrementNoteWitnesses(pindex, &block, tree);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user