chain: Rename HaveTxsDownloaded to HaveNumChainTxs
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This commit is contained in:
5 files changed
+16
-18
No files matched your search
+1
-3
@@ -280,10 +280,8 @@ public:
|
|||||||
* Note that this will be true for the snapshot base block, if one is loaded (and
|
* Note that this will be true for the snapshot base block, if one is loaded (and
|
||||||
* all subsequent assumed-valid blocks) since its nChainTx value will have been set
|
* all subsequent assumed-valid blocks) since its nChainTx value will have been set
|
||||||
* manually based on the related AssumeutxoData entry.
|
* manually based on the related AssumeutxoData entry.
|
||||||
*
|
|
||||||
* TODO: potentially change the name of this based on the fact above.
|
|
||||||
*/
|
*/
|
||||||
bool HaveTxsDownloaded() const { return nChainTx != 0; }
|
bool HaveNumChainTxs() const { return nChainTx != 0; }
|
||||||
|
|
||||||
NodeSeconds Time() const
|
NodeSeconds Time() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1448,7 +1448,7 @@ void PeerManagerImpl::FindNextBlocks(std::vector<const CBlockIndex*>& vBlocks, c
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pindex->nStatus & BLOCK_HAVE_DATA || (activeChain && activeChain->Contains(pindex))) {
|
if (pindex->nStatus & BLOCK_HAVE_DATA || (activeChain && activeChain->Contains(pindex))) {
|
||||||
if (activeChain && pindex->HaveTxsDownloaded())
|
if (activeChain && pindex->HaveNumChainTxs())
|
||||||
state->pindexLastCommonBlock = pindex;
|
state->pindexLastCommonBlock = pindex;
|
||||||
} else if (!IsBlockRequested(pindex->GetBlockHash())) {
|
} else if (!IsBlockRequested(pindex->GetBlockHash())) {
|
||||||
// The block is not already downloaded, and not yet in flight.
|
// The block is not already downloaded, and not yet in flight.
|
||||||
@@ -2233,7 +2233,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(inv.hash);
|
const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(inv.hash);
|
||||||
if (pindex) {
|
if (pindex) {
|
||||||
if (pindex->HaveTxsDownloaded() && !pindex->IsValid(BLOCK_VALID_SCRIPTS) &&
|
if (pindex->HaveNumChainTxs() && !pindex->IsValid(BLOCK_VALID_SCRIPTS) &&
|
||||||
pindex->IsValid(BLOCK_VALID_TREE)) {
|
pindex->IsValid(BLOCK_VALID_TREE)) {
|
||||||
// If we have the block and all of its parents, but have not yet validated it,
|
// If we have the block and all of its parents, but have not yet validated it,
|
||||||
// we might be in the middle of connecting it (ie in the unlock of cs_main
|
// we might be in the middle of connecting it (ie in the unlock of cs_main
|
||||||
|
|||||||
@@ -1455,7 +1455,7 @@ static RPCHelpMan getchaintips()
|
|||||||
} else if (block->nStatus & BLOCK_FAILED_MASK) {
|
} else if (block->nStatus & BLOCK_FAILED_MASK) {
|
||||||
// This block or one of its ancestors is invalid.
|
// This block or one of its ancestors is invalid.
|
||||||
status = "invalid";
|
status = "invalid";
|
||||||
} else if (!block->HaveTxsDownloaded()) {
|
} else if (!block->HaveNumChainTxs()) {
|
||||||
// This block cannot be connected because full block data for it or one of its parents is missing.
|
// This block cannot be connected because full block data for it or one of its parents is missing.
|
||||||
status = "headers-only";
|
status = "headers-only";
|
||||||
} else if (block->IsValid(BLOCK_VALID_SCRIPTS)) {
|
} else if (block->IsValid(BLOCK_VALID_SCRIPTS)) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ FUZZ_TARGET(chain)
|
|||||||
(void)disk_block_index->GetBlockTimeMax();
|
(void)disk_block_index->GetBlockTimeMax();
|
||||||
(void)disk_block_index->GetMedianTimePast();
|
(void)disk_block_index->GetMedianTimePast();
|
||||||
(void)disk_block_index->GetUndoPos();
|
(void)disk_block_index->GetUndoPos();
|
||||||
(void)disk_block_index->HaveTxsDownloaded();
|
(void)disk_block_index->HaveNumChainTxs();
|
||||||
(void)disk_block_index->IsValid();
|
(void)disk_block_index->IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -2996,7 +2996,7 @@ CBlockIndex* Chainstate::FindMostWorkChain()
|
|||||||
CBlockIndex *pindexTest = pindexNew;
|
CBlockIndex *pindexTest = pindexNew;
|
||||||
bool fInvalidAncestor = false;
|
bool fInvalidAncestor = false;
|
||||||
while (pindexTest && !m_chain.Contains(pindexTest)) {
|
while (pindexTest && !m_chain.Contains(pindexTest)) {
|
||||||
assert(pindexTest->HaveTxsDownloaded() || pindexTest->nHeight == 0);
|
assert(pindexTest->HaveNumChainTxs() || pindexTest->nHeight == 0);
|
||||||
|
|
||||||
// Pruned nodes may have entries in setBlockIndexCandidates for
|
// Pruned nodes may have entries in setBlockIndexCandidates for
|
||||||
// which block files have been deleted. Remove those as candidates
|
// which block files have been deleted. Remove those as candidates
|
||||||
@@ -3351,7 +3351,7 @@ bool Chainstate::PreciousBlock(BlockValidationState& state, CBlockIndex* pindex)
|
|||||||
// call preciousblock 2**31-1 times on the same set of tips...
|
// call preciousblock 2**31-1 times on the same set of tips...
|
||||||
m_chainman.nBlockReverseSequenceId--;
|
m_chainman.nBlockReverseSequenceId--;
|
||||||
}
|
}
|
||||||
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && pindex->HaveTxsDownloaded()) {
|
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && pindex->HaveNumChainTxs()) {
|
||||||
setBlockIndexCandidates.insert(pindex);
|
setBlockIndexCandidates.insert(pindex);
|
||||||
PruneBlockIndexCandidates();
|
PruneBlockIndexCandidates();
|
||||||
}
|
}
|
||||||
@@ -3399,7 +3399,7 @@ bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pinde
|
|||||||
if (!m_chain.Contains(candidate) &&
|
if (!m_chain.Contains(candidate) &&
|
||||||
!CBlockIndexWorkComparator()(candidate, pindex->pprev) &&
|
!CBlockIndexWorkComparator()(candidate, pindex->pprev) &&
|
||||||
candidate->IsValid(BLOCK_VALID_TRANSACTIONS) &&
|
candidate->IsValid(BLOCK_VALID_TRANSACTIONS) &&
|
||||||
candidate->HaveTxsDownloaded()) {
|
candidate->HaveNumChainTxs()) {
|
||||||
candidate_blocks_by_work.insert(std::make_pair(candidate->nChainWork, candidate));
|
candidate_blocks_by_work.insert(std::make_pair(candidate->nChainWork, candidate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3488,7 +3488,7 @@ bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pinde
|
|||||||
// Loop back over all block index entries and add any missing entries
|
// Loop back over all block index entries and add any missing entries
|
||||||
// to setBlockIndexCandidates.
|
// to setBlockIndexCandidates.
|
||||||
for (auto& [_, block_index] : m_blockman.m_block_index) {
|
for (auto& [_, block_index] : m_blockman.m_block_index) {
|
||||||
if (block_index.IsValid(BLOCK_VALID_TRANSACTIONS) && block_index.HaveTxsDownloaded() && !setBlockIndexCandidates.value_comp()(&block_index, m_chain.Tip())) {
|
if (block_index.IsValid(BLOCK_VALID_TRANSACTIONS) && block_index.HaveNumChainTxs() && !setBlockIndexCandidates.value_comp()(&block_index, m_chain.Tip())) {
|
||||||
setBlockIndexCandidates.insert(&block_index);
|
setBlockIndexCandidates.insert(&block_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3520,7 +3520,7 @@ void Chainstate::ResetBlockFailureFlags(CBlockIndex *pindex) {
|
|||||||
if (!block_index.IsValid() && block_index.GetAncestor(nHeight) == pindex) {
|
if (!block_index.IsValid() && block_index.GetAncestor(nHeight) == pindex) {
|
||||||
block_index.nStatus &= ~BLOCK_FAILED_MASK;
|
block_index.nStatus &= ~BLOCK_FAILED_MASK;
|
||||||
m_blockman.m_dirty_blockindex.insert(&block_index);
|
m_blockman.m_dirty_blockindex.insert(&block_index);
|
||||||
if (block_index.IsValid(BLOCK_VALID_TRANSACTIONS) && block_index.HaveTxsDownloaded() && setBlockIndexCandidates.value_comp()(m_chain.Tip(), &block_index)) {
|
if (block_index.IsValid(BLOCK_VALID_TRANSACTIONS) && block_index.HaveNumChainTxs() && setBlockIndexCandidates.value_comp()(m_chain.Tip(), &block_index)) {
|
||||||
setBlockIndexCandidates.insert(&block_index);
|
setBlockIndexCandidates.insert(&block_index);
|
||||||
}
|
}
|
||||||
if (&block_index == m_chainman.m_best_invalid) {
|
if (&block_index == m_chainman.m_best_invalid) {
|
||||||
@@ -3583,7 +3583,7 @@ void ChainstateManager::ReceivedBlockTransactions(const CBlock& block, CBlockInd
|
|||||||
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
|
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
|
||||||
m_blockman.m_dirty_blockindex.insert(pindexNew);
|
m_blockman.m_dirty_blockindex.insert(pindexNew);
|
||||||
|
|
||||||
if (pindexNew->pprev == nullptr || pindexNew->pprev->HaveTxsDownloaded()) {
|
if (pindexNew->pprev == nullptr || pindexNew->pprev->HaveNumChainTxs()) {
|
||||||
// If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS.
|
// If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS.
|
||||||
std::deque<CBlockIndex*> queue;
|
std::deque<CBlockIndex*> queue;
|
||||||
queue.push_back(pindexNew);
|
queue.push_back(pindexNew);
|
||||||
@@ -4566,7 +4566,7 @@ bool ChainstateManager::LoadBlockIndex()
|
|||||||
// here.
|
// here.
|
||||||
if (pindex == GetSnapshotBaseBlock() ||
|
if (pindex == GetSnapshotBaseBlock() ||
|
||||||
(pindex->IsValid(BLOCK_VALID_TRANSACTIONS) &&
|
(pindex->IsValid(BLOCK_VALID_TRANSACTIONS) &&
|
||||||
(pindex->HaveTxsDownloaded() || pindex->pprev == nullptr))) {
|
(pindex->HaveNumChainTxs() || pindex->pprev == nullptr))) {
|
||||||
|
|
||||||
for (Chainstate* chainstate : GetAll()) {
|
for (Chainstate* chainstate : GetAll()) {
|
||||||
chainstate->TryAddBlockIndexCandidate(pindex);
|
chainstate->TryAddBlockIndexCandidate(pindex);
|
||||||
@@ -4890,7 +4890,7 @@ void ChainstateManager::CheckBlockIndex()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pindex->HaveTxsDownloaded()) assert(pindex->nSequenceId <= 0); // nSequenceId can't be set positive for blocks that aren't linked (negative is used for preciousblock)
|
if (!pindex->HaveNumChainTxs()) assert(pindex->nSequenceId <= 0); // nSequenceId can't be set positive for blocks that aren't linked (negative is used for preciousblock)
|
||||||
// VALID_TRANSACTIONS is equivalent to nTx > 0 for all nodes (whether or not pruning has occurred).
|
// VALID_TRANSACTIONS is equivalent to nTx > 0 for all nodes (whether or not pruning has occurred).
|
||||||
// HAVE_DATA is only equivalent to nTx > 0 (or VALID_TRANSACTIONS) if no pruning has occurred.
|
// HAVE_DATA is only equivalent to nTx > 0 (or VALID_TRANSACTIONS) if no pruning has occurred.
|
||||||
// Unless these indexes are assumed valid and pending block download on a
|
// Unless these indexes are assumed valid and pending block download on a
|
||||||
@@ -4920,9 +4920,9 @@ void ChainstateManager::CheckBlockIndex()
|
|||||||
// actually seen a block's transactions.
|
// actually seen a block's transactions.
|
||||||
assert(((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_TRANSACTIONS) == (pindex->nTx > 0)); // This is pruning-independent.
|
assert(((pindex->nStatus & BLOCK_VALID_MASK) >= BLOCK_VALID_TRANSACTIONS) == (pindex->nTx > 0)); // This is pruning-independent.
|
||||||
}
|
}
|
||||||
// All parents having had data (at some point) is equivalent to all parents being VALID_TRANSACTIONS, which is equivalent to HaveTxsDownloaded().
|
// All parents having had data (at some point) is equivalent to all parents being VALID_TRANSACTIONS, which is equivalent to HaveNumChainTxs().
|
||||||
assert((pindexFirstNeverProcessed == nullptr) == pindex->HaveTxsDownloaded());
|
assert((pindexFirstNeverProcessed == nullptr) == pindex->HaveNumChainTxs());
|
||||||
assert((pindexFirstNotTransactionsValid == nullptr) == pindex->HaveTxsDownloaded());
|
assert((pindexFirstNotTransactionsValid == nullptr) == pindex->HaveNumChainTxs());
|
||||||
assert(pindex->nHeight == nHeight); // nHeight must be consistent.
|
assert(pindex->nHeight == nHeight); // nHeight must be consistent.
|
||||||
assert(pindex->pprev == nullptr || pindex->nChainWork >= pindex->pprev->nChainWork); // For every block except the genesis block, the chainwork must be larger than the parent's.
|
assert(pindex->pprev == nullptr || pindex->nChainWork >= pindex->pprev->nChainWork); // For every block except the genesis block, the chainwork must be larger than the parent's.
|
||||||
assert(nHeight < 2 || (pindex->pskip && (pindex->pskip->nHeight < nHeight))); // The pskip pointer must point back for all but the first 2 blocks.
|
assert(nHeight < 2 || (pindex->pskip && (pindex->pskip->nHeight < nHeight))); // The pskip pointer must point back for all but the first 2 blocks.
|
||||||
|
|||||||
Reference in new issue
Block a user