mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-25 06:55:32 +01:00
node: Track last block that received a blockTip notification
Also signal m_tip_block_cv when StopRPC is called, for consistency with g_best_block_cv. This is handled in StopRPC instead of OnRPCStopped() because the latter is deleted in a later commit. Co-authored-by: TheCharlatan <seb.kung@gmail.com> Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <common/system.h>
|
||||
#include <logging.h>
|
||||
#include <node/context.h>
|
||||
#include <node/kernel_notifications.h>
|
||||
#include <rpc/server_util.h>
|
||||
#include <rpc/util.h>
|
||||
#include <sync.h>
|
||||
@@ -311,16 +312,19 @@ void InterruptRPC()
|
||||
});
|
||||
}
|
||||
|
||||
void StopRPC()
|
||||
void StopRPC(const std::any& context)
|
||||
{
|
||||
static std::once_flag g_rpc_stop_flag;
|
||||
// This function could be called twice if the GUI has been started with -server=1.
|
||||
assert(!g_rpc_running);
|
||||
std::call_once(g_rpc_stop_flag, []() {
|
||||
std::call_once(g_rpc_stop_flag, [&]() {
|
||||
LogDebug(BCLog::RPC, "Stopping RPC\n");
|
||||
WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear());
|
||||
DeleteAuthCookie();
|
||||
g_rpcSignals.Stopped();
|
||||
node::NodeContext& node = EnsureAnyNodeContext(context);
|
||||
// The notifications interface doesn't exist between initialization step 4a and 7.
|
||||
if (node.notifications) node.notifications->m_tip_block_cv.notify_all();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user