mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-30 01:30:07 +02:00
refactor: Remove ::Params() global from inside CChainState member functions
It is confusing and verbose to repeatedly access the global when a member variable can simply refer to it.
This commit is contained in:
parent
9c1ec689f3
commit
fa38947125
@ -1210,6 +1210,7 @@ void CoinsViews::InitCache()
|
|||||||
|
|
||||||
CChainState::CChainState(CTxMemPool& mempool, BlockManager& blockman, std::optional<uint256> from_snapshot_blockhash)
|
CChainState::CChainState(CTxMemPool& mempool, BlockManager& blockman, std::optional<uint256> from_snapshot_blockhash)
|
||||||
: m_mempool(mempool),
|
: m_mempool(mempool),
|
||||||
|
m_params(::Params()),
|
||||||
m_blockman(blockman),
|
m_blockman(blockman),
|
||||||
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
|
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
|
||||||
|
|
||||||
@ -2196,20 +2197,19 @@ bool CChainState::FlushStateToDisk(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::ForceFlushStateToDisk() {
|
void CChainState::ForceFlushStateToDisk()
|
||||||
|
{
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
const CChainParams& chainparams = Params();
|
if (!this->FlushStateToDisk(m_params, state, FlushStateMode::ALWAYS)) {
|
||||||
if (!this->FlushStateToDisk(chainparams, state, FlushStateMode::ALWAYS)) {
|
|
||||||
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
|
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChainState::PruneAndFlush() {
|
void CChainState::PruneAndFlush()
|
||||||
|
{
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
fCheckForPruning = true;
|
fCheckForPruning = true;
|
||||||
const CChainParams& chainparams = Params();
|
if (!this->FlushStateToDisk(m_params, state, FlushStateMode::NONE)) {
|
||||||
|
|
||||||
if (!this->FlushStateToDisk(chainparams, state, FlushStateMode::NONE)) {
|
|
||||||
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
|
LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4507,16 +4507,14 @@ bool CChainState::ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
|
|||||||
this->ToString(), coinstip_size * (1.0 / 1024 / 1024));
|
this->ToString(), coinstip_size * (1.0 / 1024 / 1024));
|
||||||
|
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
const CChainParams& chainparams = Params();
|
|
||||||
|
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
if (coinstip_size > old_coinstip_size) {
|
if (coinstip_size > old_coinstip_size) {
|
||||||
// Likely no need to flush if cache sizes have grown.
|
// Likely no need to flush if cache sizes have grown.
|
||||||
ret = FlushStateToDisk(chainparams, state, FlushStateMode::IF_NEEDED);
|
ret = FlushStateToDisk(m_params, state, FlushStateMode::IF_NEEDED);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, flush state to disk and deallocate the in-memory coins map.
|
// Otherwise, flush state to disk and deallocate the in-memory coins map.
|
||||||
ret = FlushStateToDisk(chainparams, state, FlushStateMode::ALWAYS);
|
ret = FlushStateToDisk(m_params, state, FlushStateMode::ALWAYS);
|
||||||
CoinsTip().ReallocateCache();
|
CoinsTip().ReallocateCache();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -595,6 +595,8 @@ protected:
|
|||||||
//! mempool that is kept in sync with the chain
|
//! mempool that is kept in sync with the chain
|
||||||
CTxMemPool& m_mempool;
|
CTxMemPool& m_mempool;
|
||||||
|
|
||||||
|
const CChainParams& m_params;
|
||||||
|
|
||||||
//! Manages the UTXO set, which is a reflection of the contents of `m_chain`.
|
//! Manages the UTXO set, which is a reflection of the contents of `m_chain`.
|
||||||
std::unique_ptr<CoinsViews> m_coins_views;
|
std::unique_ptr<CoinsViews> m_coins_views;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user