@@ -1158,7 +1158,7 @@ void CoinsViews::InitCache()
11581158 m_cacheview = std::make_unique<CCoinsViewCache>(&m_catcherview);
11591159}
11601160
1161- CChainState::CChainState (CTxMemPool& mempool, BlockManager& blockman, uint256 from_snapshot_blockhash)
1161+ CChainState::CChainState (CTxMemPool& mempool, BlockManager& blockman, std::optional< uint256> from_snapshot_blockhash)
11621162 : m_mempool(mempool),
11631163 m_blockman(blockman),
11641164 m_from_snapshot_blockhash(from_snapshot_blockhash) {}
@@ -1169,8 +1169,8 @@ void CChainState::InitCoinsDB(
11691169 bool should_wipe,
11701170 std::string leveldb_name)
11711171{
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 ();
11741174 }
11751175
11761176 m_coins_views = std::make_unique<CoinsViews>(
@@ -3877,7 +3877,7 @@ bool CVerifyDB::VerifyDB(
38773877 int reportDone = 0 ;
38783878 LogPrintf (" [0%%]..." ); /* Continued */
38793879
3880- bool is_snapshot_cs = !chainstate.m_from_snapshot_blockhash . IsNull () ;
3880+ const bool is_snapshot_cs{ !chainstate.m_from_snapshot_blockhash } ;
38813881
38823882 for (pindex = chainstate.m_chain .Tip (); pindex && pindex->pprev ; pindex = pindex->pprev ) {
38833883 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()
44584458{
44594459 CBlockIndex* tip = m_chain.Tip ();
44604460 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" );
44634463}
44644464
44654465bool CChainState::ResizeCoinsCaches (size_t coinstip_size, size_t coinsdb_size)
@@ -4662,10 +4662,10 @@ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex *pin
46624662 return std::min<double >(pindex->nChainTx / fTxTotal , 1.0 );
46634663}
46644664
4665- std::optional<uint256> ChainstateManager::SnapshotBlockhash () const {
4665+ std::optional<uint256> ChainstateManager::SnapshotBlockhash () const
4666+ {
46664667 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 ) {
46694669 // If a snapshot chainstate exists, it will always be our active.
46704670 return m_active_chainstate->m_from_snapshot_blockhash ;
46714671 }
@@ -4688,9 +4688,9 @@ std::vector<CChainState*> ChainstateManager::GetAll()
46884688 return out;
46894689}
46904690
4691- CChainState& ChainstateManager::InitializeChainstate (CTxMemPool& mempool, const uint256& snapshot_blockhash)
4691+ CChainState& ChainstateManager::InitializeChainstate (CTxMemPool& mempool, const std::optional< uint256> & snapshot_blockhash)
46924692{
4693- bool is_snapshot = ! snapshot_blockhash.IsNull ();
4693+ bool is_snapshot = snapshot_blockhash.has_value ();
46944694 std::unique_ptr<CChainState>& to_modify =
46954695 is_snapshot ? m_snapshot_chainstate : m_ibd_chainstate;
46964696
0 commit comments