mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Make m_tip_block an std::optional
This change avoids ambiguity when no tip is connected and it is compared to uint256::ZERO.
This commit is contained in:
@@ -973,7 +973,9 @@ public:
|
||||
{
|
||||
WAIT_LOCK(notifications().m_tip_block_mutex, lock);
|
||||
notifications().m_tip_block_cv.wait_for(lock, timeout, [&]() EXCLUSIVE_LOCKS_REQUIRED(notifications().m_tip_block_mutex) {
|
||||
return (notifications().m_tip_block != current_tip && notifications().m_tip_block != uint256::ZERO) || chainman().m_interrupt;
|
||||
// We need to wait for m_tip_block to be set AND for the value
|
||||
// to differ from the current_tip value.
|
||||
return (notifications().m_tip_block && notifications().m_tip_block != current_tip) || chainman().m_interrupt;
|
||||
});
|
||||
}
|
||||
// Must release m_tip_block_mutex before locking cs_main, to avoid deadlocks.
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
//! The block for which the last blockTip notification was received.
|
||||
//! It's first set when the tip is connected during node initialization.
|
||||
//! Might be unset during an early shutdown.
|
||||
uint256 m_tip_block GUARDED_BY(m_tip_block_mutex){uint256::ZERO};
|
||||
std::optional<uint256> m_tip_block GUARDED_BY(m_tip_block_mutex);
|
||||
|
||||
private:
|
||||
const std::function<bool()>& m_shutdown_request;
|
||||
|
||||
Reference in New Issue
Block a user