@@ -36,8 +36,8 @@ static constexpr auto WAIT_FOR_ISLOCK_TIMEOUT{10min};
3636} // anonymous namespace
3737
3838namespace chainlock {
39- ChainlockHandler::ChainlockHandler (chainlock::Chainlocks& chainlocks, ChainstateManager& chainman,
40- CTxMemPool& _mempool, const CMasternodeSync& mn_sync) :
39+ ChainlockHandler::ChainlockHandler (chainlock::Chainlocks& chainlocks, ChainstateManager& chainman, CTxMemPool& _mempool,
40+ const CMasternodeSync& mn_sync) :
4141 m_chainlocks{chainlocks},
4242 m_chainman{chainman},
4343 mempool{_mempool},
@@ -65,10 +65,7 @@ void ChainlockHandler::Start()
6565 std::chrono::seconds{5 });
6666}
6767
68- void ChainlockHandler::Stop ()
69- {
70- scheduler->stop ();
71- }
68+ void ChainlockHandler::Stop () { scheduler->stop (); }
7269
7370bool ChainlockHandler::AlreadyHave (const CInv& inv) const
7471{
@@ -85,8 +82,8 @@ void ChainlockHandler::UpdateTxFirstSeenMap(const Uint256HashSet& tx, const int6
8582 }
8683}
8784
88- MessageProcessingResult ChainlockHandler::ProcessNewChainLock (const NodeId from, const chainlock::ChainLockSig& clsig, const llmq::CQuorumManager& qman,
89- const uint256& hash)
85+ MessageProcessingResult ChainlockHandler::ProcessNewChainLock (const NodeId from, const chainlock::ChainLockSig& clsig,
86+ const llmq::CQuorumManager& qman, const uint256& hash)
9087{
9188 CheckActiveState ();
9289
@@ -103,7 +100,8 @@ MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from,
103100 }
104101 }
105102
106- if (const auto ret = chainlock::VerifyChainLock (Params ().GetConsensus (), m_chainman.ActiveChain (), qman, clsig); ret != llmq::VerifyRecSigStatus::Valid) {
103+ if (const auto ret = chainlock::VerifyChainLock (Params ().GetConsensus (), m_chainman.ActiveChain (), qman, clsig);
104+ ret != llmq::VerifyRecSigStatus::Valid) {
107105 LogPrint (BCLog::CHAINLOCKS, " ChainlockHandler::%s -- invalid CLSIG (%s), status=%d peer=%d\n " , __func__,
108106 clsig.ToString (), ToUnderlying (ret), from);
109107 if (from != -1 ) {
@@ -131,15 +129,15 @@ MessageProcessingResult ChainlockHandler::ProcessNewChainLock(const NodeId from,
131129 return clsig_inv;
132130}
133131
134- void ChainlockHandler::UpdatedBlockTip (const CBlockIndex * pindexNew, const CBlockIndex * pindexFork, bool fInitialDownload )
132+ void ChainlockHandler::UpdatedBlockTip (const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload )
135133{
136134 if (pindexNew == pindexFork) // blocks were disconnected without any new ones
137135 return ;
138136 if (fInitialDownload ) return ;
139137
140- // TODO: reconsider removing scheduler from here, because UpdatedBlockTip is already async call from notification scheduler
141- // don't call TrySignChainTip directly but instead let the scheduler call it. This way we ensure that cs_main is
142- // never locked and TrySignChainTip is not called twice in parallel. Also avoids recursive calls due to
138+ // TODO: reconsider removing scheduler from here, because UpdatedBlockTip is already async call from notification
139+ // scheduler don't call TrySignChainTip directly but instead let the scheduler call it. This way we ensure that
140+ // cs_main is never locked and TrySignChainTip is not called twice in parallel. Also avoids recursive calls due to
143141 // EnforceBestChainLock switching chains.
144142 // atomic[If tryLockChainTipScheduled is false, do (set it to true] and schedule signing).
145143
@@ -253,8 +251,7 @@ void ChainlockHandler::EnforceBestChainLock()
253251 return ;
254252 }
255253 LOCK (::cs_main);
256- if (m_chainman.ActiveTip ()->GetAncestor (currentBestChainLockBlockIndex->nHeight ) !=
257- currentBestChainLockBlockIndex) {
254+ if (m_chainman.ActiveTip ()->GetAncestor (currentBestChainLockBlockIndex->nHeight ) != currentBestChainLockBlockIndex) {
258255 return ;
259256 }
260257 }
@@ -265,7 +262,8 @@ void ChainlockHandler::EnforceBestChainLock()
265262 lastNotifyChainLockBlockIndex = currentBestChainLockBlockIndex;
266263 }
267264
268- GetMainSignals ().NotifyChainLock (currentBestChainLockBlockIndex, std::make_shared<chainlock::ChainLockSig>(clsig), clsig.ToString ());
265+ GetMainSignals ().NotifyChainLock (currentBestChainLockBlockIndex, std::make_shared<chainlock::ChainLockSig>(clsig),
266+ clsig.ToString ());
269267 uiInterface.NotifyChainLock (clsig.getBlockHash ().ToString (), clsig.getHeight ());
270268 ::g_stats_client->gauge (" chainlocks.blockHeight" , clsig.getHeight (), 1 .0f );
271269}
@@ -325,12 +323,13 @@ void ChainlockHandler::Cleanup()
325323 }
326324}
327325
328- llmq::VerifyRecSigStatus VerifyChainLock (const Consensus::Params& params, const CChain& chain, const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig)
326+ llmq::VerifyRecSigStatus VerifyChainLock (const Consensus::Params& params, const CChain& chain,
327+ const llmq::CQuorumManager& qman, const chainlock::ChainLockSig& clsig)
329328{
330329 const auto llmqType = params.llmqTypeChainLocks ;
331330 const uint256 request_id = chainlock::GenSigRequestId (clsig.getHeight ());
332331
333- return llmq::VerifyRecoveredSig (llmqType, chain, qman, clsig.getHeight (), request_id,
334- clsig.getBlockHash (), clsig. getSig ());
332+ return llmq::VerifyRecoveredSig (llmqType, chain, qman, clsig.getHeight (), request_id, clsig. getBlockHash (),
333+ clsig.getSig ());
335334}
336335} // namespace chainlock
0 commit comments