@@ -142,16 +142,16 @@ PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock(const CNode& pfrom
142142 return tl::unexpected{100 };
143143 }
144144
145- if (WITH_LOCK (cs_pendingLocks, return pendingInstantSendLocks.count (hash) || pendingNoTxInstantSendLocks.count (hash))
146- || db.KnownInstantSendLock (hash)) {
145+ if (WITH_LOCK (cs_pendingLocks, return pendingInstantSendLocks.count (hash) || pendingNoTxInstantSendLocks.count (hash)) ||
146+ db.KnownInstantSendLock (hash)) {
147147 return {};
148148 }
149149
150150 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: received islock, peer=%d\n " , __func__,
151- islock->txid .ToString (), hash.ToString (), pfrom.GetId ());
151+ islock->txid .ToString (), hash.ToString (), pfrom.GetId ());
152152
153153 if (ShouldReportISLockTiming ()) {
154- auto time_diff = [&] () -> int64_t {
154+ auto time_diff = [&]() -> int64_t {
155155 LOCK (cs_timingsTxSeen);
156156 if (auto it = timingsTxSeen.find (islock->txid ); it != timingsTxSeen.end ()) {
157157 // This is the normal case where we received the TX before the islock
@@ -164,7 +164,7 @@ PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock(const CNode& pfrom
164164 }();
165165 ::g_stats_client->timing (" islock_ms" , time_diff);
166166 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock took %dms\n " , __func__,
167- islock->txid .ToString (), time_diff);
167+ islock->txid .ToString (), time_diff);
168168 }
169169
170170 LOCK (cs_pendingLocks);
@@ -209,7 +209,7 @@ bool CInstantSendManager::ProcessPendingInstantSendLocks(PeerManager& peerman)
209209 return false ;
210210 }
211211
212- // TODO Investigate if leaving this is ok
212+ // TODO Investigate if leaving this is ok
213213 auto llmqType = Params ().GetConsensus ().llmqTypeDIP0024InstantSend ;
214214 const auto & llmq_params_opt = Params ().GetLLMQ (llmqType);
215215 assert (llmq_params_opt);
@@ -222,7 +222,7 @@ bool CInstantSendManager::ProcessPendingInstantSendLocks(PeerManager& peerman)
222222 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- doing verification on old active set\n " , __func__);
223223
224224 // filter out valid IS locks from "pend"
225- for (auto it = pend.begin (); it != pend.end (); ) {
225+ for (auto it = pend.begin (); it != pend.end ();) {
226226 if (!badISLocks.count (it->first )) {
227227 it = pend.erase (it);
228228 } else {
@@ -238,7 +238,8 @@ bool CInstantSendManager::ProcessPendingInstantSendLocks(PeerManager& peerman)
238238
239239std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPendingInstantSendLocks (
240240 const Consensus::LLMQParams& llmq_params, PeerManager& peerman, int signOffset,
241- const std::unordered_map<uint256, std::pair<NodeId, instantsend::InstantSendLockPtr>, StaticSaltedHasher>& pend, bool ban)
241+ const std::unordered_map<uint256, std::pair<NodeId, instantsend::InstantSendLockPtr>, StaticSaltedHasher>& pend,
242+ bool ban)
242243{
243244 CBLSBatchVerifier<NodeId, uint256> batchVerifier (false , true , 8 );
244245 std::unordered_map<uint256, CRecoveredSig, StaticSaltedHasher> recSigs;
@@ -295,7 +296,8 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
295296 // avoids unnecessary double-verification of the signature. We however only do this when verification here
296297 // turns out to be good (which is checked further down)
297298 if (!sigman.HasRecoveredSigForId (llmq_params.type , id)) {
298- recSigs.try_emplace (hash, CRecoveredSig (llmq_params.type , quorum->qc ->quorumHash , id, islock->txid , islock->sig ));
299+ recSigs.try_emplace (hash,
300+ CRecoveredSig (llmq_params.type , quorum->qc ->quorumHash , id, islock->txid , islock->sig ));
299301 }
300302 }
301303
@@ -322,8 +324,8 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
322324 const auto & islock = p.second .second ;
323325
324326 if (batchVerifier.badMessages .count (hash)) {
325- LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: invalid sig in islock, peer=%d\n " , __func__,
326- islock->txid .ToString (), hash.ToString (), nodeId);
327+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: invalid sig in islock, peer=%d\n " ,
328+ __func__, islock->txid .ToString (), hash.ToString (), nodeId);
327329 badISLocks.emplace (hash);
328330 continue ;
329331 }
@@ -349,8 +351,8 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
349351void CInstantSendManager::ProcessInstantSendLock (NodeId from, PeerManager& peerman, const uint256& hash,
350352 const instantsend::InstantSendLockPtr& islock)
351353{
352- LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: processing islock, peer=%d\n " , __func__,
353- islock->txid .ToString (), hash.ToString (), from);
354+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: processing islock, peer=%d\n " ,
355+ __func__, islock->txid .ToString (), hash.ToString (), from);
354356 if (m_signer) {
355357 m_signer->ClearLockFromQueue (islock);
356358 }
@@ -418,7 +420,7 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, PeerManager& peerm
418420 if (tx != nullptr ) {
419421 RemoveMempoolConflictsForLock (peerman, hash, *islock);
420422 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- notify about lock %s for tx %s\n " , __func__,
421- hash.ToString (), tx->GetHash ().ToString ());
423+ hash.ToString (), tx->GetHash ().ToString ());
422424 GetMainSignals ().NotifyTransactionLock (tx, islock);
423425 // bump mempool counter to make sure newly locked txes are picked up by getblocktemplate
424426 mempool.AddTransactionsUpdated (1 );
@@ -474,7 +476,8 @@ void CInstantSendManager::TransactionRemovedFromMempool(const CTransactionRef& t
474476 return ;
475477 }
476478
477- LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- transaction %s was removed from mempool\n " , __func__, tx->GetHash ().ToString ());
479+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- transaction %s was removed from mempool\n " , __func__,
480+ tx->GetHash ().ToString ());
478481 RemoveConflictingLock (::SerializeHash (*islock), *islock);
479482}
480483
@@ -508,7 +511,8 @@ void CInstantSendManager::BlockConnected(const std::shared_ptr<const CBlock>& pb
508511 db.WriteBlockInstantSendLocks (pblock, pindex);
509512}
510513
511- void CInstantSendManager::BlockDisconnected (const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected)
514+ void CInstantSendManager::BlockDisconnected (const std::shared_ptr<const CBlock>& pblock,
515+ const CBlockIndex* pindexDisconnected)
512516{
513517 db.RemoveBlockInstantSendLocks (pblock, pindexDisconnected);
514518}
@@ -523,7 +527,7 @@ void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx, const CBlock
523527
524528 if (did_insert) {
525529 nonLockedTxInfo.tx = tx;
526- for (const auto &in : tx->vin ) {
530+ for (const auto & in : tx->vin ) {
527531 nonLockedTxs[in.prevout .hash ].children .emplace (tx->GetHash ());
528532 nonLockedTxsByOutpoints.emplace (in.prevout , tx->GetHash ());
529533 }
@@ -591,8 +595,8 @@ void CInstantSendManager::RemoveNonLockedTx(const uint256& txid, bool retryChild
591595
592596 nonLockedTxs.erase (it);
593597
594- LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, retryChildren=%d, retryChildrenCount=%d\n " , __func__,
595- txid.ToString (), retryChildren, retryChildrenCount);
598+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, retryChildren=%d, retryChildrenCount=%d\n " ,
599+ __func__, txid.ToString (), retryChildren, retryChildrenCount);
596600}
597601
598602void CInstantSendManager::RemoveConflictedTx (const CTransaction& tx)
@@ -614,7 +618,8 @@ void CInstantSendManager::TruncateRecoveredSigsForInputs(const instantsend::Inst
614618 }
615619}
616620
617- void CInstantSendManager::TryEmplacePendingLock (const uint256& hash, const NodeId id, const instantsend::InstantSendLockPtr& islock)
621+ void CInstantSendManager::TryEmplacePendingLock (const uint256& hash, const NodeId id,
622+ const instantsend::InstantSendLockPtr& islock)
618623{
619624 if (db.KnownInstantSendLock (hash)) return ;
620625 LOCK (cs_pendingLocks);
@@ -673,7 +678,7 @@ void CInstantSendManager::HandleFullyConfirmedBlock(const CBlockIndex* pindex)
673678 std::vector<uint256> toRemove;
674679 {
675680 LOCK (cs_nonLocked);
676- for (const auto & p: nonLockedTxs) {
681+ for (const auto & p : nonLockedTxs) {
677682 const auto * pindexMined = p.second .pindexMined ;
678683
679684 if (pindexMined && pindex->GetAncestor (pindexMined->nHeight ) == pindexMined) {
@@ -704,7 +709,7 @@ void CInstantSendManager::RemoveMempoolConflictsForLock(PeerManager& peerman, co
704709 toDelete.emplace (it->second ->GetHash (), mempool.get (it->second ->GetHash ()));
705710
706711 LogPrintf (" CInstantSendManager::%s -- txid=%s, islock=%s: mempool TX %s with input %s conflicts with islock\n " , __func__,
707- islock.txid .ToString (), hash.ToString (), it->second ->GetHash ().ToString (), in.ToStringShort ());
712+ islock.txid .ToString (), hash.ToString (), it->second ->GetHash ().ToString (), in.ToStringShort ());
708713 }
709714 }
710715
@@ -761,16 +766,17 @@ void CInstantSendManager::ResolveBlockConflicts(const uint256& islockHash, const
761766
762767 // If a conflict was mined into a ChainLocked block, then we have no other choice and must prune the ISLOCK and all
763768 // chained ISLOCKs that build on top of this one. The probability of this is practically zero and can only happen
764- // when large parts of the masternode network are controlled by an attacker. In this case we must still find consensus
765- // and its better to sacrifice individual ISLOCKs then to sacrifice whole ChainLocks.
769+ // when large parts of the masternode network are controlled by an attacker. In this case we must still find
770+ // consensus and its better to sacrifice individual ISLOCKs then to sacrifice whole ChainLocks.
766771 if (hasChainLockedConflict) {
767- LogPrintf (" CInstantSendManager::%s -- txid=%s, islock=%s: at least one conflicted TX already got a ChainLock\n " , __func__,
768- islock.txid .ToString (), islockHash.ToString ());
772+ LogPrintf (" CInstantSendManager::%s -- txid=%s, islock=%s: at least one conflicted TX already got a ChainLock\n " ,
773+ __func__, islock.txid .ToString (), islockHash.ToString ());
769774 RemoveConflictingLock (islockHash, islock);
770775 return ;
771776 }
772777
773- bool isLockedTxKnown = WITH_LOCK (cs_pendingLocks, return pendingNoTxInstantSendLocks.find (islockHash) == pendingNoTxInstantSendLocks.end ());
778+ bool isLockedTxKnown = WITH_LOCK (cs_pendingLocks, return pendingNoTxInstantSendLocks.find (islockHash) ==
779+ pendingNoTxInstantSendLocks.end ());
774780
775781 bool activateBestChain = false ;
776782 for (const auto & p : conflicts) {
@@ -828,8 +834,9 @@ bool CInstantSendManager::AlreadyHave(const CInv& inv) const
828834 return true ;
829835 }
830836
831- return WITH_LOCK (cs_pendingLocks, return pendingInstantSendLocks.count (inv.hash ) != 0 || pendingNoTxInstantSendLocks.count (inv.hash ) != 0 )
832- || db.KnownInstantSendLock (inv.hash );
837+ return WITH_LOCK (cs_pendingLocks, return pendingInstantSendLocks.count (inv.hash ) != 0 ||
838+ pendingNoTxInstantSendLocks.count (inv.hash ) != 0 ) ||
839+ db.KnownInstantSendLock (inv.hash );
833840}
834841
835842bool CInstantSendManager::GetInstantSendLockByHash (const uint256& hash, instantsend::InstantSendLock& ret) const
@@ -885,8 +892,8 @@ bool CInstantSendManager::IsWaitingForTx(const uint256& txHash) const
885892 auto it = pendingNoTxInstantSendLocks.begin ();
886893 while (it != pendingNoTxInstantSendLocks.end ()) {
887894 if (it->second .second ->txid == txHash) {
888- LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s\n " , __func__,
889- txHash. ToString (), it->first .ToString ());
895+ LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s\n " , __func__, txHash. ToString (),
896+ it->first .ToString ());
890897 return true ;
891898 }
892899 ++it;
@@ -967,5 +974,4 @@ bool CInstantSendManager::RejectConflictingBlocks() const
967974 }
968975 return true ;
969976}
970-
971977} // namespace llmq
0 commit comments