6
6
#define BITCOIN_EVO_MNHFTX_H
7
7
8
8
#include < bls/bls.h>
9
+ #include < gsl/pointers.h>
9
10
#include < primitives/transaction.h>
10
11
#include < sync.h>
11
12
#include < threadsafety.h>
@@ -99,6 +100,7 @@ class CMNHFManager : public AbstractEHFManager
99
100
{
100
101
private:
101
102
CEvoDB& m_evoDb;
103
+ llmq::CQuorumManager* m_qman{nullptr };
102
104
103
105
static constexpr size_t MNHFCacheSize = 1000 ;
104
106
Mutex cs_cache;
@@ -115,24 +117,45 @@ class CMNHFManager : public AbstractEHFManager
115
117
/* *
116
118
* Every new block should be processed when Tip() is updated by calling of CMNHFManager::ProcessBlock.
117
119
* This function actually does only validate EHF transaction for this block and update internal caches/evodb state
120
+ *
121
+ * @pre Caller must ensure that LLMQContext has been initialized and the llmq::CQuorumManager pointer has been
122
+ * set by calling ConnectManagers() for this CMNHFManager instance
118
123
*/
119
124
std::optional<Signals> ProcessBlock (const CBlock& block, const CBlockIndex* const pindex, bool fJustCheck , BlockValidationState& state);
120
125
121
126
/* *
122
127
* Every undo block should be processed when Tip() is updated by calling of CMNHFManager::UndoBlock
123
- * This function actually does nothing at the moment, because status of ancestor block is already know .
128
+ * This function actually does nothing at the moment, because status of ancestor block is already known .
124
129
* Although it should be still called to do some sanity checks
130
+ *
131
+ * @pre Caller must ensure that LLMQContext has been initialized and the llmq::CQuorumManager pointer has been
132
+ * set by calling ConnectManagers() for this CMNHFManager instance
125
133
*/
126
134
bool UndoBlock (const CBlock& block, const CBlockIndex* const pindex);
127
135
128
-
129
136
// Implements interface
130
137
Signals GetSignalsStage (const CBlockIndex* const pindexPrev) override ;
131
138
132
139
/* *
133
140
* Helper that used in Unit Test to forcely setup EHF signal for specific block
134
141
*/
135
142
void AddSignal (const CBlockIndex* const pindex, int bit) EXCLUSIVE_LOCKS_REQUIRED(!cs_cache);
143
+
144
+ /* *
145
+ * Set llmq::CQuorumManager pointer.
146
+ *
147
+ * Separated from constructor to allow LLMQContext to use CMNHFManager in read-only capacity.
148
+ * Required to mutate state.
149
+ */
150
+ void ConnectManagers (gsl::not_null<llmq::CQuorumManager*> qman);
151
+
152
+ /* *
153
+ * Reset llmq::CQuorumManager pointer.
154
+ *
155
+ * @pre Must be called before LLMQContext (containing llmq::CQuorumManager) is destroyed.
156
+ */
157
+ void DisconnectManagers () { m_qman = nullptr ; };
158
+
136
159
private:
137
160
void AddToCache (const Signals& signals, const CBlockIndex* const pindex);
138
161
0 commit comments