From 52992ebe1c55c8f7219b824f05d22fbc18acb794 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Fri, 20 Feb 2026 14:23:32 -0800 Subject: [PATCH] interfaces: Add waitForNotifications() to call SyncWithValidationInterfaceQueue() Co-Authored-By: stickies-v --- src/interfaces/chain.h | 6 ++++++ src/node/interfaces.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index e6847b9b161..20369fd2e26 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -326,12 +326,18 @@ public: }; //! Register handler for notifications. + //! Some notifications are asynchronous and may still execute after the handler is disconnected. + //! Use waitForNotifications() after the handler is disconnected to ensure all pending notifications + //! have been processed. virtual std::unique_ptr handleNotifications(std::shared_ptr notifications) = 0; //! Wait for pending notifications to be processed unless block hash points to the current //! chain tip. virtual void waitForNotificationsIfTipChanged(const uint256& old_tip) = 0; + //! Wait for all pending notifications up to this point to be processed + virtual void waitForNotifications() = 0; + //! Register handler for RPC. Command is not copied, so reference //! needs to remain valid until Handler is disconnected. virtual std::unique_ptr handleRpc(const CRPCCommand& command) = 0; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 8f5406ab3c0..16fb977035c 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -785,6 +785,10 @@ public: if (!old_tip.IsNull() && old_tip == WITH_LOCK(::cs_main, return chainman().ActiveChain().Tip()->GetBlockHash())) return; validation_signals().SyncWithValidationInterfaceQueue(); } + void waitForNotifications() override + { + validation_signals().SyncWithValidationInterfaceQueue(); + } std::unique_ptr handleRpc(const CRPCCommand& command) override { return std::make_unique(command);