mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Add helper to wait for validation interface queue to catch up
This commit is contained in:
parent
36137497f1
commit
97d2b09c12
4 changed files with 24 additions and 11 deletions
|
|
@ -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] {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue