mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Merge ea53568a06 into merged_master (Bitcoin PR bitcoin/bitcoin#31393)
This commit is contained in:
commit
1d5f60cb85
5 changed files with 24 additions and 18 deletions
|
|
@ -3419,9 +3419,9 @@ void Chainstate::PruneAndFlush()
|
|||
}
|
||||
|
||||
static void UpdateTipLog(
|
||||
const ChainstateManager& chainman,
|
||||
const CCoinsViewCache& coins_tip,
|
||||
const CBlockIndex* tip,
|
||||
const CChainParams& params,
|
||||
const std::string& func_name,
|
||||
const std::string& prefix,
|
||||
const std::string& warning_messages) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
|
|
@ -3433,7 +3433,7 @@ static void UpdateTipLog(
|
|||
tip->GetBlockHash().ToString(), tip->nHeight, tip->nVersion,
|
||||
log(tip->nChainWork.getdouble()) / log(2.0), tip->m_chain_tx_count,
|
||||
FormatISO8601DateTime(tip->GetBlockTime()),
|
||||
GuessVerificationProgress(tip, params.GetConsensus().nPowTargetSpacing),
|
||||
chainman.GuessVerificationProgress(tip),
|
||||
coins_tip.DynamicMemoryUsage() * (1.0 / (1 << 20)),
|
||||
coins_tip.GetCacheSize(),
|
||||
!warning_messages.empty() ? strprintf(" warning='%s'", warning_messages) : "");
|
||||
|
|
@ -3456,15 +3456,13 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
|
|||
AssertLockHeld(::cs_main);
|
||||
const auto& coins_tip = this->CoinsTip();
|
||||
|
||||
const CChainParams& params{m_chainman.GetParams()};
|
||||
|
||||
// The remainder of the function isn't relevant if we are not acting on
|
||||
// the active chainstate, so return if need be.
|
||||
if (this != &m_chainman.ActiveChainstate()) {
|
||||
// Only log every so often so that we don't bury log messages at the tip.
|
||||
constexpr int BACKGROUND_LOG_INTERVAL = 2000;
|
||||
if (pindexNew->nHeight % BACKGROUND_LOG_INTERVAL == 0) {
|
||||
UpdateTipLog(coins_tip, pindexNew, params, __func__, "[background validation] ", "");
|
||||
UpdateTipLog(m_chainman, coins_tip, pindexNew, __func__, "[background validation] ", "");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -3479,7 +3477,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
|
|||
const CBlockIndex* pindex = pindexNew;
|
||||
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
|
||||
WarningBitsConditionChecker checker(m_chainman, bit);
|
||||
ThresholdState state = checker.GetStateFor(pindex, params.GetConsensus(), m_chainman.m_warningcache.at(bit));
|
||||
ThresholdState state = checker.GetStateFor(pindex, m_chainman.GetConsensus(), m_chainman.m_warningcache.at(bit));
|
||||
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
|
||||
const bilingual_str warning = strprintf(_("Unknown new rules activated (versionbit %i)"), bit);
|
||||
if (state == ThresholdState::ACTIVE) {
|
||||
|
|
@ -3490,7 +3488,7 @@ void Chainstate::UpdateTip(const CBlockIndex* pindexNew)
|
|||
}
|
||||
}
|
||||
}
|
||||
UpdateTipLog(coins_tip, pindexNew, params, __func__, "",
|
||||
UpdateTipLog(m_chainman, coins_tip, pindexNew, __func__, "",
|
||||
util::Join(warning_messages, Untranslated(", ")).original);
|
||||
|
||||
ForceUntrimHeader(pindexNew);
|
||||
|
|
@ -5354,7 +5352,7 @@ bool Chainstate::LoadChainTip()
|
|||
tip->GetBlockHash().ToString(),
|
||||
m_chain.Height(),
|
||||
FormatISO8601DateTime(tip->GetBlockTime()),
|
||||
GuessVerificationProgress(tip, m_chainman.GetConsensus().nPowTargetSpacing));
|
||||
m_chainman.GuessVerificationProgress(tip));
|
||||
|
||||
// Ensure KernelNotifications m_tip_block is set even if no new block arrives.
|
||||
if (this->GetRole() != ChainstateRole::BACKGROUND) {
|
||||
|
|
@ -6243,7 +6241,6 @@ bool Chainstate::ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//! Guess how far we are in the verification process at the given block index.
|
||||
//! Since we have signed fixed-interval blocks, estimating progress is a very easy.
|
||||
//! We can extrapolate the last block time to the current time to estimate how many more blocks
|
||||
|
|
@ -6262,6 +6259,13 @@ double GuessVerificationProgress(const CBlockIndex* pindex, int64_t blockInterva
|
|||
return std::min(1.0, progress);
|
||||
}
|
||||
|
||||
//! Guess how far we are in the verification process at the given block index
|
||||
//! require cs_main if pindex has not been validated yet (because m_chain_tx_count might be unset)
|
||||
double ChainstateManager::GuessVerificationProgress(const CBlockIndex* pindex) const
|
||||
{
|
||||
return ::GuessVerificationProgress(pindex, GetConsensus().nPowTargetSpacing);
|
||||
}
|
||||
|
||||
std::optional<uint256> ChainstateManager::SnapshotBlockhash() const
|
||||
{
|
||||
LOCK(::cs_main);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue