6
6
#ifndef BITCOIN_VALIDATIONINTERFACE_H
7
7
#define BITCOIN_VALIDATIONINTERFACE_H
8
8
9
- #include < memory>
10
-
11
9
#include " primitives/transaction.h" // CTransaction(Ref)
12
10
11
+ #include < functional>
12
+ #include < memory>
13
+
13
14
class CBlock ;
14
15
class CBlockIndex ;
15
16
struct CBlockLocator ;
@@ -31,6 +32,16 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn);
31
32
void UnregisterValidationInterface (CValidationInterface* pwalletIn);
32
33
/* * Unregister all wallets from core */
33
34
void UnregisterAllValidationInterfaces ();
35
+ /* *
36
+ * Pushes a function to callback onto the notification queue, guaranteeing any
37
+ * callbacks generated prior to now are finished when the function is called.
38
+ *
39
+ * Be very careful blocking on func to be called if any locks are held -
40
+ * validation interface clients may not be able to make progress as they often
41
+ * wait for things like cs_main, so blocking until func is called with cs_main
42
+ * will result in a deadlock (that DEBUG_LOCKORDER will miss).
43
+ */
44
+ void CallFunctionInValidationInterfaceQueue (std::function<void ()> func);
34
45
35
46
class CValidationInterface {
36
47
protected:
@@ -86,6 +97,7 @@ class CMainSignals {
86
97
friend void ::RegisterValidationInterface (CValidationInterface*);
87
98
friend void ::UnregisterValidationInterface (CValidationInterface*);
88
99
friend void ::UnregisterAllValidationInterfaces ();
100
+ friend void ::CallFunctionInValidationInterfaceQueue (std::function<void ()> func);
89
101
90
102
void MempoolEntryRemoved (CTransactionRef tx, MemPoolRemovalReason reason);
91
103
0 commit comments