interfaces: Add waitForNotifications() to call SyncWithValidationInterfaceQueue()
What changed, and why it matters
This commit adds a new public interface method that lets callers wait for background notification processing to finish. It is a straightforward API addition with no security relevance visible in the diff or commit message.
No security action needed. Treat as a normal API/functional change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change introduces Chain::waitForNotifications(), implemented in node/interfaces.cpp as a direct call to validation_signals().SyncWithValidationInterfaceQueue(). It also updates the documentation for handleNotifications() to note that some notifications are asynchronous and that waitForNotifications() can be used after disconnecting a handler. There is no bug fix, no change to existing behavior, and no security-related content.
Changed components
src/interfaces/chain.hsrc/node/interfaces.cppInspect captured patch +10 / −0
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
index e6847b9b..20369fd2 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<Handler> handleNotifications(std::shared_ptr<Notifications> 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<Handler> handleRpc(const CRPCCommand& command) = 0;
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 8f5406ab..16fb9770 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<Handler> handleRpc(const CRPCCommand& command) override
{
return std::make_unique<RpcHandlerImpl>(command);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.