@@ -1158,7 +1158,7 @@ void CoinsViews::InitCache()
1158
1158
m_cacheview = std::make_unique<CCoinsViewCache>(&m_catcherview);
1159
1159
}
1160
1160
1161
- CChainState::CChainState (CTxMemPool& mempool, BlockManager& blockman, uint256 from_snapshot_blockhash)
1161
+ CChainState::CChainState (CTxMemPool& mempool, BlockManager& blockman, std::optional< uint256> from_snapshot_blockhash)
1162
1162
: m_mempool(mempool),
1163
1163
m_blockman(blockman),
1164
1164
m_from_snapshot_blockhash(from_snapshot_blockhash) {}
@@ -1169,8 +1169,8 @@ void CChainState::InitCoinsDB(
1169
1169
bool should_wipe,
1170
1170
std::string leveldb_name)
1171
1171
{
1172
- if (! m_from_snapshot_blockhash. IsNull () ) {
1173
- leveldb_name += " _" + m_from_snapshot_blockhash. ToString ();
1172
+ if (m_from_snapshot_blockhash) {
1173
+ leveldb_name += " _" + m_from_snapshot_blockhash-> ToString ();
1174
1174
}
1175
1175
1176
1176
m_coins_views = std::make_unique<CoinsViews>(
@@ -3877,7 +3877,7 @@ bool CVerifyDB::VerifyDB(
3877
3877
int reportDone = 0 ;
3878
3878
LogPrintf (" [0%%]..." ); /* Continued */
3879
3879
3880
- bool is_snapshot_cs = !chainstate.m_from_snapshot_blockhash . IsNull () ;
3880
+ const bool is_snapshot_cs{ !chainstate.m_from_snapshot_blockhash } ;
3881
3881
3882
3882
for (pindex = chainstate.m_chain .Tip (); pindex && pindex->pprev ; pindex = pindex->pprev ) {
3883
3883
const int percentageDone = std::max (1 , std::min (99 , (int )(((double )(chainstate.m_chain .Height () - pindex->nHeight )) / (double )nCheckDepth * (nCheckLevel >= 4 ? 50 : 100 ))));
@@ -4458,8 +4458,8 @@ std::string CChainState::ToString()
4458
4458
{
4459
4459
CBlockIndex* tip = m_chain.Tip ();
4460
4460
return strprintf (" Chainstate [%s] @ height %d (%s)" ,
4461
- m_from_snapshot_blockhash. IsNull () ? " ibd " : " snapshot " ,
4462
- tip ? tip->nHeight : -1 , tip ? tip->GetBlockHash ().ToString () : " null" );
4461
+ m_from_snapshot_blockhash ? " snapshot " : " ibd " ,
4462
+ tip ? tip->nHeight : -1 , tip ? tip->GetBlockHash ().ToString () : " null" );
4463
4463
}
4464
4464
4465
4465
bool CChainState::ResizeCoinsCaches (size_t coinstip_size, size_t coinsdb_size)
@@ -4662,10 +4662,10 @@ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex *pin
4662
4662
return std::min<double >(pindex->nChainTx / fTxTotal , 1.0 );
4663
4663
}
4664
4664
4665
- std::optional<uint256> ChainstateManager::SnapshotBlockhash () const {
4665
+ std::optional<uint256> ChainstateManager::SnapshotBlockhash () const
4666
+ {
4666
4667
LOCK (::cs_main);
4667
- if (m_active_chainstate != nullptr &&
4668
- !m_active_chainstate->m_from_snapshot_blockhash .IsNull ()) {
4668
+ if (m_active_chainstate && m_active_chainstate->m_from_snapshot_blockhash ) {
4669
4669
// If a snapshot chainstate exists, it will always be our active.
4670
4670
return m_active_chainstate->m_from_snapshot_blockhash ;
4671
4671
}
@@ -4688,9 +4688,9 @@ std::vector<CChainState*> ChainstateManager::GetAll()
4688
4688
return out;
4689
4689
}
4690
4690
4691
- CChainState& ChainstateManager::InitializeChainstate (CTxMemPool& mempool, const uint256& snapshot_blockhash)
4691
+ CChainState& ChainstateManager::InitializeChainstate (CTxMemPool& mempool, const std::optional< uint256> & snapshot_blockhash)
4692
4692
{
4693
- bool is_snapshot = ! snapshot_blockhash.IsNull ();
4693
+ bool is_snapshot = snapshot_blockhash.has_value ();
4694
4694
std::unique_ptr<CChainState>& to_modify =
4695
4695
is_snapshot ? m_snapshot_chainstate : m_ibd_chainstate;
4696
4696
0 commit comments