mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Add helper to wait for validation interface queue to catch up
This commit is contained in:
@@ -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] {
|
||||
|
||||
Reference in New Issue
Block a user