diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-04-27 21:06:48 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-06-13 09:39:37 +0200 |
commit | fa389471251f043ec25e7b01e59b37d3b921ce54 (patch) | |
tree | b3ad8c756e1cf7a5d7659e87b5e6563715b1abbf /src/validation.cpp | |
parent | 9c1ec689f353d3d7c34695a074f82bb2ea449538 (diff) |
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.
Diffstat (limited to 'src/validation.cpp')
-rw-r--r-- | src/validation.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index b48e49a10b..857be660fe 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1210,6 +1210,7 @@ void CoinsViews::InitCache() CChainState::CChainState(CTxMemPool& mempool, BlockManager& blockman, std::optional<uint256> from_snapshot_blockhash) : m_mempool(mempool), + m_params(::Params()), m_blockman(blockman), m_from_snapshot_blockhash(from_snapshot_blockhash) {} @@ -2196,20 +2197,19 @@ bool CChainState::FlushStateToDisk( return true; } -void CChainState::ForceFlushStateToDisk() { +void CChainState::ForceFlushStateToDisk() +{ BlockValidationState state; - const CChainParams& chainparams = Params(); - if (!this->FlushStateToDisk(chainparams, state, FlushStateMode::ALWAYS)) { + if (!this->FlushStateToDisk(m_params, state, FlushStateMode::ALWAYS)) { LogPrintf("%s: failed to flush state (%s)\n", __func__, state.ToString()); } } -void CChainState::PruneAndFlush() { +void CChainState::PruneAndFlush() +{ BlockValidationState state; fCheckForPruning = true; - const CChainParams& chainparams = Params(); - - if (!this->FlushStateToDisk(chainparams, state, FlushStateMode::NONE)) { + if (!this->FlushStateToDisk(m_params, state, FlushStateMode::NONE)) { 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)); BlockValidationState state; - const CChainParams& chainparams = Params(); - bool ret; if (coinstip_size > old_coinstip_size) { // 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 { // 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(); } return ret; |