aboutsummaryrefslogtreecommitdiff
path: root/src/validationinterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/validationinterface.cpp')
-rw-r--r--src/validationinterface.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
index abbd8cc4d2..928df4fa65 100644
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2016 The Bitcoin Core developers
+// Copyright (c) 2009-2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -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>
@@ -54,6 +56,11 @@ void CMainSignals::FlushBackgroundCallbacks() {
}
}
+size_t CMainSignals::CallbacksPending() {
+ if (!m_internals) return 0;
+ return m_internals->m_schedulerClient.CallbacksPending();
+}
+
void CMainSignals::RegisterWithMempoolSignals(CTxMemPool& pool) {
pool.NotifyEntryRemoved.connect(boost::bind(&CMainSignals::MempoolEntryRemoved, this, _1, _2));
}
@@ -113,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] {