interfaces: Add waitForNotifications() to call SyncWithValidationInterfaceQueue()
Co-Authored-By: stickies-v <stickies-v@protonmail.com>
This commit is contained in:
1 parent
ce6898f9a8
commit
52992ebe1c
2 files changed
+10
No files matched your search
@@ -326,12 +326,18 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Register handler for notifications.
|
//! 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;
|
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
|
//! Wait for pending notifications to be processed unless block hash points to the current
|
||||||
//! chain tip.
|
//! chain tip.
|
||||||
virtual void waitForNotificationsIfTipChanged(const uint256& old_tip) = 0;
|
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
|
//! Register handler for RPC. Command is not copied, so reference
|
||||||
//! needs to remain valid until Handler is disconnected.
|
//! needs to remain valid until Handler is disconnected.
|
||||||
virtual std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) = 0;
|
virtual std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) = 0;
|
||||||
|
|||||||
@@ -785,6 +785,10 @@ public:
|
|||||||
if (!old_tip.IsNull() && old_tip == WITH_LOCK(::cs_main, return chainman().ActiveChain().Tip()->GetBlockHash())) return;
|
if (!old_tip.IsNull() && old_tip == WITH_LOCK(::cs_main, return chainman().ActiveChain().Tip()->GetBlockHash())) return;
|
||||||
validation_signals().SyncWithValidationInterfaceQueue();
|
validation_signals().SyncWithValidationInterfaceQueue();
|
||||||
}
|
}
|
||||||
|
void waitForNotifications() override
|
||||||
|
{
|
||||||
|
validation_signals().SyncWithValidationInterfaceQueue();
|
||||||
|
}
|
||||||
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
|
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
|
||||||
{
|
{
|
||||||
return std::make_unique<RpcHandlerImpl>(command);
|
return std::make_unique<RpcHandlerImpl>(command);
|
||||||
|
|||||||
Reference in new issue
Block a user