Skip to content

Commit 637a90b

Browse files
committed
add Chainstate::HasCoinsViews()
Used in subsequent commits. Also cleans up asserts in coins_views-related convenience methods to be more exact.
1 parent c29f26b commit 637a90b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/validation.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,15 @@ class Chainstate
553553
CCoinsViewCache& CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
554554
{
555555
AssertLockHeld(::cs_main);
556-
assert(m_coins_views->m_cacheview);
557-
return *m_coins_views->m_cacheview.get();
556+
Assert(m_coins_views);
557+
return *Assert(m_coins_views->m_cacheview);
558558
}
559559

560560
//! @returns A reference to the on-disk UTXO set database.
561561
CCoinsViewDB& CoinsDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
562562
{
563563
AssertLockHeld(::cs_main);
564-
return m_coins_views->m_dbview;
564+
return Assert(m_coins_views)->m_dbview;
565565
}
566566

567567
//! @returns A pointer to the mempool.
@@ -575,12 +575,15 @@ class Chainstate
575575
CCoinsViewErrorCatcher& CoinsErrorCatcher() EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
576576
{
577577
AssertLockHeld(::cs_main);
578-
return m_coins_views->m_catcherview;
578+
return Assert(m_coins_views)->m_catcherview;
579579
}
580580

581581
//! Destructs all objects related to accessing the UTXO set.
582582
void ResetCoinsViews() { m_coins_views.reset(); }
583583

584+
//! Does this chainstate have a UTXO set attached?
585+
bool HasCoinsViews() const { return (bool)m_coins_views; }
586+
584587
//! The cache size of the on-disk coins view.
585588
size_t m_coinsdb_cache_size_bytes{0};
586589

0 commit comments

Comments
 (0)