aboutsummaryrefslogtreecommitdiff
path: root/src/validationinterface.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2017-12-24 12:13:13 -0500
committerMatt Corallo <git@bluematt.me>2017-12-26 11:56:00 -0500
commit97d2b09c124e6e5803f7fd4503348d9710d1260f (patch)
tree03f9de627168be7e5ae8a95b6d345b754496a517 /src/validationinterface.cpp
parent36137497f1e2b3324ca84550f4f295dcd605d1fa (diff)
Add helper to wait for validation interface queue to catch up
Diffstat (limited to 'src/validationinterface.cpp')
-rw-r--r--src/validationinterface.cpp12
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] {