interfaces: Add waitForNotifications() to call SyncWithValidationInterfaceQueue()

Co-Authored-By: stickies-v <stickies-v@protonmail.com>
This commit is contained in:
Ava Chow 2026-02-20 14:23:32 -08:00
parent ce6898f9a8
commit 52992ebe1c
2 changed files with 10 additions and 0 deletions

View File

@ -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;

View File

@ -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);