mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
refactor: Split up NodeContext shutdown_signal and shutdown_request
Instead of having a single NodeContext::shutdown member that is used both to request shutdowns and check if they have been requested, use separate members for each. Benefits of this change: 1. Should make code a little clearer and easier to search because it is easier to see which parts of code are triggering shutdowns and which parts are just checking to see if they were triggered. 2. Makes it possible for init.cpp to specify additional code to run when a shutdown is requested, like signalling the m_tip_block_cv condition variable. Motivation for this change was to remove hacky NodeContext argument and m_tip_block_cv access from the StopRPC function, so StopRPC can just be concerned with RPC functionality, not other node functionality.
This commit is contained in:
@@ -58,7 +58,7 @@ kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state
|
||||
|
||||
uiInterface.NotifyBlockTip(state, &index);
|
||||
if (m_stop_at_height && index.nHeight >= m_stop_at_height) {
|
||||
if (!m_shutdown()) {
|
||||
if (!m_shutdown_request()) {
|
||||
LogError("Failed to send shutdown signal after reaching stop height\n");
|
||||
}
|
||||
return kernel::Interrupted{};
|
||||
@@ -90,12 +90,12 @@ void KernelNotifications::warningUnset(kernel::Warning id)
|
||||
|
||||
void KernelNotifications::flushError(const bilingual_str& message)
|
||||
{
|
||||
AbortNode(&m_shutdown, m_exit_status, message, &m_warnings);
|
||||
AbortNode(m_shutdown_request, m_exit_status, message, &m_warnings);
|
||||
}
|
||||
|
||||
void KernelNotifications::fatalError(const bilingual_str& message)
|
||||
{
|
||||
node::AbortNode(m_shutdown_on_fatal_error ? &m_shutdown : nullptr,
|
||||
node::AbortNode(m_shutdown_on_fatal_error ? m_shutdown_request : nullptr,
|
||||
m_exit_status, message, &m_warnings);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user