diff options
Diffstat (limited to 'src/validationinterface.cpp')
-rw-r--r-- | src/validationinterface.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 1ddff4b335..1e13465bf7 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -11,9 +11,11 @@ #include <sync.h> #include <txmempool.h> #include <util.h> +#include <validation.h> #include <list> #include <atomic> +#include <future> #include <boost/signals2/signal.hpp> @@ -118,6 +120,16 @@ void CallFunctionInValidationInterfaceQueue(std::function<void ()> func) { g_signals.m_internals->m_schedulerClient.AddToProcessQueue(std::move(func)); } +void SyncWithValidationInterfaceQueue() { + AssertLockNotHeld(cs_main); + // Block until the validation queue drains + std::promise<void> promise; + CallFunctionInValidationInterfaceQueue([&promise] { + promise.set_value(); + }); + promise.get_future().wait(); +} + void CMainSignals::MempoolEntryRemoved(CTransactionRef ptx, MemPoolRemovalReason reason) { if (reason != MemPoolRemovalReason::BLOCK && reason != MemPoolRemovalReason::CONFLICT) { m_internals->m_schedulerClient.AddToProcessQueue([ptx, this] { |