@@ -29,14 +29,14 @@ CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMe
2929
3030using node::GetTransaction;
3131
32- namespace llmq {
3332namespace {
3433static constexpr auto CLEANUP_SEEN_TIMEOUT {24h};
3534// ! How long to wait for islocks until we consider a block with non-islocked TXs to be safe to sign
3635static constexpr auto WAIT_FOR_ISLOCK_TIMEOUT {10min};
3736} // anonymous namespace
3837
39- CChainLocksHandler::CChainLocksHandler (chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
38+ namespace chainlock {
39+ ChainlockHandler::ChainlockHandler (chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
4040 CTxMemPool& _mempool, const CMasternodeSync& mn_sync) :
4141 m_chainlocks{chainlocks},
4242 m_chainman{chainman},
@@ -48,13 +48,13 @@ CChainLocksHandler::CChainLocksHandler(chainlock::Chainlocks& chainlocks, Chains
4848{
4949}
5050
51- CChainLocksHandler ::~CChainLocksHandler ()
51+ ChainlockHandler ::~ChainlockHandler ()
5252{
5353 scheduler->stop ();
5454 scheduler_thread->join ();
5555}
5656
57- void CChainLocksHandler ::Start ()
57+ void ChainlockHandler ::Start ()
5858{
5959 scheduler->scheduleEvery (
6060 [&]() {
@@ -65,18 +65,18 @@ void CChainLocksHandler::Start()
6565 std::chrono::seconds{5 });
6666}
6767
68- void CChainLocksHandler ::Stop ()
68+ void ChainlockHandler ::Stop ()
6969{
7070 scheduler->stop ();
7171}
7272
73- bool CChainLocksHandler ::AlreadyHave (const CInv& inv) const
73+ bool ChainlockHandler ::AlreadyHave (const CInv& inv) const
7474{
7575 LOCK (cs);
7676 return seenChainLocks.count (inv.hash ) != 0 ;
7777}
7878
79- void CChainLocksHandler ::UpdateTxFirstSeenMap (const Uint256HashSet& tx, const int64_t & time)
79+ void ChainlockHandler ::UpdateTxFirstSeenMap (const Uint256HashSet& tx, const int64_t & time)
8080{
8181 AssertLockNotHeld (cs);
8282 LOCK (cs);
@@ -85,7 +85,7 @@ void CChainLocksHandler::UpdateTxFirstSeenMap(const Uint256HashSet& tx, const in
8585 }
8686}
8787
88- MessageProcessingResult CChainLocksHandler ::ProcessNewChainLock (const NodeId from, const chainlock::ChainLockSig& clsig, const llmq::CQuorumManager& qman,
88+ MessageProcessingResult ChainlockHandler ::ProcessNewChainLock (const NodeId from, const chainlock::ChainLockSig& clsig, const llmq::CQuorumManager& qman,
8989 const uint256& hash)
9090{
9191 CheckActiveState ();
@@ -103,8 +103,8 @@ MessageProcessingResult CChainLocksHandler::ProcessNewChainLock(const NodeId fro
103103 }
104104 }
105105
106- if (const auto ret = chainlock::VerifyChainLock (Params ().GetConsensus (), m_chainman.ActiveChain (), qman, clsig); ret != VerifyRecSigStatus::Valid) {
107- LogPrint (BCLog::CHAINLOCKS , " CChainLocksHandler ::%s -- invalid CLSIG (%s), status=%d peer=%d\n " , __func__,
106+ if (const auto ret = chainlock::VerifyChainLock (Params ().GetConsensus (), m_chainman.ActiveChain (), qman, clsig); ret != llmq:: VerifyRecSigStatus::Valid) {
107+ LogPrint (BCLog::CHAINLOCKS , " ChainlockHandler ::%s -- invalid CLSIG (%s), status=%d peer=%d\n " , __func__,
108108 clsig.ToString (), ToUnderlying (ret), from);
109109 if (from != -1 ) {
110110 return MisbehavingError{10 };
@@ -124,14 +124,14 @@ MessageProcessingResult CChainLocksHandler::ProcessNewChainLock(const NodeId fro
124124 },
125125 std::chrono::seconds{0 });
126126
127- LogPrint (BCLog::CHAINLOCKS , " CChainLocksHandler ::%s -- processed new CLSIG (%s), peer=%d\n " , __func__,
127+ LogPrint (BCLog::CHAINLOCKS , " ChainlockHandler ::%s -- processed new CLSIG (%s), peer=%d\n " , __func__,
128128 clsig.ToString (), from);
129129 }
130130 const CInv clsig_inv (MSG_CLSIG , hash);
131131 return clsig_inv;
132132}
133133
134- void CChainLocksHandler ::UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload )
134+ void ChainlockHandler ::UpdatedBlockTip (const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload )
135135{
136136 if (pindexNew == pindexFork) // blocks were disconnected without any new ones
137137 return ;
@@ -155,7 +155,7 @@ void CChainLocksHandler::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBl
155155 }
156156}
157157
158- void CChainLocksHandler ::CheckActiveState ()
158+ void ChainlockHandler ::CheckActiveState ()
159159{
160160 bool oldIsEnabled = isEnabled;
161161 isEnabled = m_chainlocks.IsEnabled ();
@@ -170,7 +170,7 @@ void CChainLocksHandler::CheckActiveState()
170170 }
171171}
172172
173- void CChainLocksHandler ::TransactionAddedToMempool (const CTransactionRef& tx, int64_t nAcceptTime, uint64_t )
173+ void ChainlockHandler ::TransactionAddedToMempool (const CTransactionRef& tx, int64_t nAcceptTime, uint64_t )
174174{
175175 if (tx->IsCoinBase () || tx->vin .empty ()) {
176176 return ;
@@ -180,12 +180,12 @@ void CChainLocksHandler::TransactionAddedToMempool(const CTransactionRef& tx, in
180180 txFirstSeenTime.emplace (tx->GetHash (), nAcceptTime);
181181}
182182
183- void CChainLocksHandler ::AcceptedBlockHeader (const CBlockIndex* pindexNew)
183+ void ChainlockHandler ::AcceptedBlockHeader (const CBlockIndex* pindexNew)
184184{
185185 m_chainlocks.AcceptedBlockHeader (pindexNew);
186186}
187187
188- void CChainLocksHandler ::BlockConnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
188+ void ChainlockHandler ::BlockConnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
189189{
190190 if (!m_mn_sync.IsBlockchainSynced ()) {
191191 return ;
@@ -203,7 +203,7 @@ void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& pbl
203203 }
204204}
205205
206- bool CChainLocksHandler ::IsTxSafeForMining (const uint256& txid) const
206+ bool ChainlockHandler ::IsTxSafeForMining (const uint256& txid) const
207207{
208208 auto tx_age{0s};
209209 {
@@ -219,7 +219,7 @@ bool CChainLocksHandler::IsTxSafeForMining(const uint256& txid) const
219219
220220// WARNING: cs_main and cs should not be held!
221221// This should also not be called from validation signals, as this might result in recursive calls
222- void CChainLocksHandler ::EnforceBestChainLock ()
222+ void ChainlockHandler ::EnforceBestChainLock ()
223223{
224224 if (!isEnabled) {
225225 return ;
@@ -240,7 +240,7 @@ void CChainLocksHandler::EnforceBestChainLock()
240240 // Go backwards through the chain referenced by clsig until we find a block that is part of the main chain.
241241 // For each of these blocks, check if there are children that are NOT part of the chain referenced by clsig
242242 // and mark all of them as conflicting.
243- LogPrint (BCLog::CHAINLOCKS , " CChainLocksHandler ::%s -- enforcing block %s via CLSIG (%s)\n " , __func__,
243+ LogPrint (BCLog::CHAINLOCKS , " ChainlockHandler ::%s -- enforcing block %s via CLSIG (%s)\n " , __func__,
244244 currentBestChainLockBlockIndex->GetBlockHash ().ToString (), clsig.ToString ());
245245 m_chainman.ActiveChainstate ().EnforceBlock (dummy_state, currentBestChainLockBlockIndex);
246246
@@ -249,7 +249,7 @@ void CChainLocksHandler::EnforceBestChainLock()
249249 currentBestChainLockBlockIndex->nHeight )) !=
250250 currentBestChainLockBlockIndex) {
251251 if (!m_chainman.ActiveChainstate ().ActivateBestChain (dummy_state)) {
252- LogPrintf (" CChainLocksHandler ::%s -- ActivateBestChain failed: %s\n " , __func__, dummy_state.ToString ());
252+ LogPrintf (" ChainlockHandler ::%s -- ActivateBestChain failed: %s\n " , __func__, dummy_state.ToString ());
253253 return ;
254254 }
255255 LOCK (::cs_main);
@@ -270,7 +270,7 @@ void CChainLocksHandler::EnforceBestChainLock()
270270 ::g_stats_client->gauge (" chainlocks.blockHeight" , clsig.getHeight (), 1 .0f );
271271}
272272
273- void CChainLocksHandler ::CleanupFromSigner (const std::vector<std::shared_ptr<Uint256HashSet>>& cleanup_txes)
273+ void ChainlockHandler ::CleanupFromSigner (const std::vector<std::shared_ptr<Uint256HashSet>>& cleanup_txes)
274274{
275275 LOCK (cs);
276276 for (const auto & tx : cleanup_txes) {
@@ -280,7 +280,7 @@ void CChainLocksHandler::CleanupFromSigner(const std::vector<std::shared_ptr<Uin
280280 }
281281}
282282
283- void CChainLocksHandler ::Cleanup ()
283+ void ChainlockHandler ::Cleanup ()
284284{
285285 constexpr auto CLEANUP_INTERVAL {30s};
286286 if (!m_mn_sync.IsBlockchainSynced ()) {
@@ -324,10 +324,7 @@ void CChainLocksHandler::Cleanup()
324324 }
325325 }
326326}
327- } // namespace llmq
328327
329- namespace chainlock
330- {
331328llmq::VerifyRecSigStatus VerifyChainLock (const Consensus::Params& params, const CChain& chain, const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig)
332329{
333330 const auto llmqType = params.llmqTypeChainLocks ;
0 commit comments