mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Merge dbdc83ae01 into merged_master (Bitcoin PR bitcoin/bitcoin#24909)
This commit is contained in:
commit
d4aa6eba2f
12 changed files with 104 additions and 104 deletions
|
|
@ -75,7 +75,6 @@ using node::CBlockIndexHeightOnlyComparator;
|
|||
using node::CBlockIndexWorkComparator;
|
||||
using node::CCoinsStats;
|
||||
using node::CoinStatsHashType;
|
||||
using node::fHavePruned;
|
||||
using node::fImporting;
|
||||
using node::fPruneMode;
|
||||
using node::fReindex;
|
||||
|
|
@ -126,7 +125,6 @@ const std::vector<std::string> CHECKLEVEL_DOC {
|
|||
*/
|
||||
RecursiveMutex cs_main;
|
||||
|
||||
CBlockIndex *pindexBestHeader = nullptr;
|
||||
Mutex g_best_block_mutex;
|
||||
std::condition_variable g_best_block_cv;
|
||||
uint256 g_best_block;
|
||||
|
|
@ -292,8 +290,9 @@ static bool IsCurrentForFeeEstimation(CChainState& active_chainstate) EXCLUSIVE_
|
|||
return false;
|
||||
if (active_chainstate.m_chain.Tip()->GetBlockTime() < count_seconds(GetTime<std::chrono::seconds>() - MAX_FEE_ESTIMATION_TIP_AGE))
|
||||
return false;
|
||||
if (active_chainstate.m_chain.Height() < pindexBestHeader->nHeight - 1)
|
||||
if (active_chainstate.m_chain.Height() < active_chainstate.m_chainman.m_best_header->nHeight - 1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1695,8 +1694,8 @@ void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
|
|||
if (!m_chainman.m_best_invalid || pindexNew->nChainWork > m_chainman.m_best_invalid->nChainWork) {
|
||||
m_chainman.m_best_invalid = pindexNew;
|
||||
}
|
||||
if (pindexBestHeader != nullptr && pindexBestHeader->GetAncestor(pindexNew->nHeight) == pindexNew) {
|
||||
pindexBestHeader = m_chain.Tip();
|
||||
if (m_chainman.m_best_header != nullptr && m_chainman.m_best_header->GetAncestor(pindexNew->nHeight) == pindexNew) {
|
||||
m_chainman.m_best_header = m_chain.Tip();
|
||||
}
|
||||
|
||||
LogPrintf("%s: invalid block=%s height=%d date=%s\n", __func__,
|
||||
|
|
@ -2216,8 +2215,8 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
BlockMap::const_iterator it = m_blockman.m_block_index.find(hashAssumeValid);
|
||||
if (it != m_blockman.m_block_index.end()) {
|
||||
if (it->second.GetAncestor(pindex->nHeight) == pindex &&
|
||||
pindexBestHeader->GetAncestor(pindex->nHeight) == pindex &&
|
||||
pindexBestHeader->nChainWork >= nMinimumChainWork) {
|
||||
m_chainman.m_best_header->GetAncestor(pindex->nHeight) == pindex &&
|
||||
m_chainman.m_best_header->nChainWork >= nMinimumChainWork) {
|
||||
// This block is a member of the assumed verified chain and an ancestor of the best header.
|
||||
// Script verification is skipped when connecting blocks under the
|
||||
// assumevalid block. Assuming the assumevalid block is valid this
|
||||
|
|
@ -2232,7 +2231,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
// artificially set the default assumed verified block further back.
|
||||
// The test against nMinimumChainWork prevents the skipping when denied access to any chain at
|
||||
// least as good as the expected chain.
|
||||
fScriptChecks = (GetBlockProofEquivalentTime(*pindexBestHeader, *pindex, *pindexBestHeader, m_params.GetConsensus()) <= 60 * 60 * 24 * 7 * 2);
|
||||
fScriptChecks = (GetBlockProofEquivalentTime(*m_chainman.m_best_header, *pindex, *m_chainman.m_best_header, m_params.GetConsensus()) <= 60 * 60 * 24 * 7 * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2584,9 +2583,9 @@ bool CChainState::FlushStateToDisk(
|
|||
}
|
||||
if (!setFilesToPrune.empty()) {
|
||||
fFlushForPrune = true;
|
||||
if (!fHavePruned) {
|
||||
if (!m_blockman.m_have_pruned) {
|
||||
m_blockman.m_block_tree_db->WriteFlag("prunedblockfiles", true);
|
||||
fHavePruned = true;
|
||||
m_blockman.m_have_pruned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3191,7 +3190,7 @@ static bool NotifyHeaderTip(CChainState& chainstate) LOCKS_EXCLUDED(cs_main) {
|
|||
CBlockIndex* pindexHeader = nullptr;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindexHeader = pindexBestHeader;
|
||||
pindexHeader = chainstate.m_chainman.m_best_header;
|
||||
|
||||
if (pindexHeader != pindexHeaderOld) {
|
||||
fNotify = true;
|
||||
|
|
@ -4049,7 +4048,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
|
|||
}
|
||||
}
|
||||
}
|
||||
CBlockIndex* pindex{m_blockman.AddToBlockIndex(block)};
|
||||
CBlockIndex* pindex{m_blockman.AddToBlockIndex(block, m_best_header)};
|
||||
|
||||
if (ppindex)
|
||||
*ppindex = pindex;
|
||||
|
|
@ -4559,13 +4558,11 @@ void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
|
|||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
chainman.Unload();
|
||||
pindexBestHeader = nullptr;
|
||||
if (mempool) mempool->clear();
|
||||
g_versionbitscache.Clear();
|
||||
for (int b = 0; b < VERSIONBITS_NUM_BITS; b++) {
|
||||
warningcache[b].clear();
|
||||
}
|
||||
fHavePruned = false;
|
||||
}
|
||||
|
||||
bool ChainstateManager::LoadBlockIndex()
|
||||
|
|
@ -4640,6 +4637,8 @@ bool ChainstateManager::LoadBlockIndex()
|
|||
if (pindex->nStatus & BLOCK_FAILED_MASK && (!m_best_invalid || pindex->nChainWork > m_best_invalid->nChainWork)) {
|
||||
m_best_invalid = pindex;
|
||||
}
|
||||
if (pindex->IsValid(BLOCK_VALID_TREE) && (m_best_header == nullptr || CBlockIndexWorkComparator()(m_best_header, pindex)))
|
||||
m_best_header = pindex;
|
||||
}
|
||||
|
||||
needs_init = m_blockman.m_block_index.empty();
|
||||
|
|
@ -4674,7 +4673,7 @@ bool CChainState::LoadGenesisBlock()
|
|||
if (blockPos.IsNull()) {
|
||||
return error("%s: writing genesis block to disk failed", __func__);
|
||||
}
|
||||
CBlockIndex *pindex = m_blockman.AddToBlockIndex(block);
|
||||
CBlockIndex* pindex = m_blockman.AddToBlockIndex(block, m_chainman.m_best_header);
|
||||
ReceivedBlockTransactions(block, pindex, blockPos);
|
||||
} catch (const std::runtime_error& e) {
|
||||
return error("%s: failed to write genesis block: %s", __func__, e.what());
|
||||
|
|
@ -4885,7 +4884,7 @@ void CChainState::CheckBlockIndex()
|
|||
// 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
|
||||
// background chainstate.
|
||||
if (!fHavePruned && !pindex->IsAssumedValid()) {
|
||||
if (!m_blockman.m_have_pruned && !pindex->IsAssumedValid()) {
|
||||
// If we've never pruned, then HAVE_DATA should be equivalent to nTx > 0
|
||||
assert(!(pindex->nStatus & BLOCK_HAVE_DATA) == (pindex->nTx == 0));
|
||||
assert(pindexFirstMissing == pindexFirstNeverProcessed);
|
||||
|
|
@ -4959,7 +4958,7 @@ void CChainState::CheckBlockIndex()
|
|||
if (pindexFirstMissing == nullptr) assert(!foundInUnlinked); // We aren't missing data for any parent -- cannot be in m_blocks_unlinked.
|
||||
if (pindex->pprev && (pindex->nStatus & BLOCK_HAVE_DATA) && pindexFirstNeverProcessed == nullptr && pindexFirstMissing != nullptr) {
|
||||
// We HAVE_DATA for this block, have received data for all parents at some point, but we're currently missing data for some parent.
|
||||
assert(fHavePruned); // We must have pruned.
|
||||
assert(m_blockman.m_have_pruned); // We must have pruned.
|
||||
// This block may have entered m_blocks_unlinked if:
|
||||
// - it has a descendant that at some point had more work than the
|
||||
// tip, and
|
||||
|
|
@ -5605,6 +5604,7 @@ void ChainstateManager::Unload()
|
|||
|
||||
m_failed_blocks.clear();
|
||||
m_blockman.Unload();
|
||||
m_best_header = nullptr;
|
||||
m_best_invalid = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue