@@ -1210,6 +1210,7 @@ void CoinsViews::InitCache()
1210
1210
1211
1211
CChainState::CChainState (CTxMemPool& mempool, BlockManager& blockman, std::optional<uint256> from_snapshot_blockhash)
1212
1212
: m_mempool(mempool),
1213
+ m_params(::Params()),
1213
1214
m_blockman(blockman),
1214
1215
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
1215
1216
@@ -2196,20 +2197,19 @@ bool CChainState::FlushStateToDisk(
2196
2197
return true ;
2197
2198
}
2198
2199
2199
- void CChainState::ForceFlushStateToDisk () {
2200
+ void CChainState::ForceFlushStateToDisk ()
2201
+ {
2200
2202
BlockValidationState state;
2201
- const CChainParams& chainparams = Params ();
2202
- if (!this ->FlushStateToDisk (chainparams, state, FlushStateMode::ALWAYS)) {
2203
+ if (!this ->FlushStateToDisk (m_params, state, FlushStateMode::ALWAYS)) {
2203
2204
LogPrintf (" %s: failed to flush state (%s)\n " , __func__, state.ToString ());
2204
2205
}
2205
2206
}
2206
2207
2207
- void CChainState::PruneAndFlush () {
2208
+ void CChainState::PruneAndFlush ()
2209
+ {
2208
2210
BlockValidationState state;
2209
2211
fCheckForPruning = true ;
2210
- const CChainParams& chainparams = Params ();
2211
-
2212
- if (!this ->FlushStateToDisk (chainparams, state, FlushStateMode::NONE)) {
2212
+ if (!this ->FlushStateToDisk (m_params, state, FlushStateMode::NONE)) {
2213
2213
LogPrintf (" %s: failed to flush state (%s)\n " , __func__, state.ToString ());
2214
2214
}
2215
2215
}
@@ -4507,16 +4507,14 @@ bool CChainState::ResizeCoinsCaches(size_t coinstip_size, size_t coinsdb_size)
4507
4507
this ->ToString (), coinstip_size * (1.0 / 1024 / 1024 ));
4508
4508
4509
4509
BlockValidationState state;
4510
- const CChainParams& chainparams = Params ();
4511
-
4512
4510
bool ret;
4513
4511
4514
4512
if (coinstip_size > old_coinstip_size) {
4515
4513
// Likely no need to flush if cache sizes have grown.
4516
- ret = FlushStateToDisk (chainparams , state, FlushStateMode::IF_NEEDED);
4514
+ ret = FlushStateToDisk (m_params , state, FlushStateMode::IF_NEEDED);
4517
4515
} else {
4518
4516
// Otherwise, flush state to disk and deallocate the in-memory coins map.
4519
- ret = FlushStateToDisk (chainparams , state, FlushStateMode::ALWAYS);
4517
+ ret = FlushStateToDisk (m_params , state, FlushStateMode::ALWAYS);
4520
4518
CoinsTip ().ReallocateCache ();
4521
4519
}
4522
4520
return ret;
0 commit comments