@@ -430,14 +430,14 @@ std::vector<uint256> CInstantSendDb::RemoveChainedInstantSendLocks(const uint256
430430// //////////////
431431
432432
433- void CInstantSendManager::Start ()
433+ void CInstantSendManager::Start (PeerManager& peerman )
434434{
435435 // can't start new thread if we have one running already
436436 if (workThread.joinable ()) {
437437 assert (false );
438438 }
439439
440- workThread = std::thread (&util::TraceThread, " isman" , [this ] { WorkThreadMain (); });
440+ workThread = std::thread (&util::TraceThread, " isman" , [this , &peerman ] { WorkThreadMain (peerman ); });
441441
442442 sigman.RegisterRecoveredSigsListener (this );
443443}
@@ -732,21 +732,23 @@ void CInstantSendManager::HandleNewInstantSendLockRecoveredSig(const llmq::CReco
732732 pendingInstantSendLocks.emplace (hash, std::make_pair (-1 , islock));
733733}
734734
735- PeerMsgRet CInstantSendManager::ProcessMessage (const CNode& pfrom, std::string_view msg_type, CDataStream& vRecv)
735+ PeerMsgRet CInstantSendManager::ProcessMessage (const CNode& pfrom, PeerManager& peerman, std::string_view msg_type,
736+ CDataStream& vRecv)
736737{
737738 if (IsInstantSendEnabled () && msg_type == NetMsgType::ISDLOCK) {
738739 const auto islock = std::make_shared<CInstantSendLock>();
739740 vRecv >> *islock;
740- return ProcessMessageInstantSendLock (pfrom, islock);
741+ return ProcessMessageInstantSendLock (pfrom, peerman, islock);
741742 }
742743 return {};
743744}
744745
745- PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock (const CNode& pfrom, const llmq::CInstantSendLockPtr& islock)
746+ PeerMsgRet CInstantSendManager::ProcessMessageInstantSendLock (const CNode& pfrom, PeerManager& peerman,
747+ const llmq::CInstantSendLockPtr& islock)
746748{
747749 auto hash = ::SerializeHash (*islock);
748750
749- WITH_LOCK (::cs_main, Assert (m_peerman)-> EraseObjectRequest (pfrom.GetId (), CInv (MSG_ISDLOCK, hash)));
751+ WITH_LOCK (::cs_main, peerman. EraseObjectRequest (pfrom.GetId (), CInv (MSG_ISDLOCK, hash)));
750752
751753 if (!islock->TriviallyValid ()) {
752754 return tl::unexpected{100 };
@@ -800,7 +802,7 @@ bool CInstantSendLock::TriviallyValid() const
800802 return true ;
801803}
802804
803- bool CInstantSendManager::ProcessPendingInstantSendLocks ()
805+ bool CInstantSendManager::ProcessPendingInstantSendLocks (PeerManager& peerman )
804806{
805807 decltype (pendingInstantSendLocks) pend;
806808 bool fMoreWork {false };
@@ -845,7 +847,7 @@ bool CInstantSendManager::ProcessPendingInstantSendLocks()
845847 auto dkgInterval = llmq_params.dkgInterval ;
846848
847849 // First check against the current active set and don't ban
848- auto badISLocks = ProcessPendingInstantSendLocks (llmq_params, 0 , pend, false );
850+ auto badISLocks = ProcessPendingInstantSendLocks (llmq_params, peerman, /* signOffset= */ 0 , pend, false );
849851 if (!badISLocks.empty ()) {
850852 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- doing verification on old active set\n " , __func__);
851853
@@ -858,13 +860,15 @@ bool CInstantSendManager::ProcessPendingInstantSendLocks()
858860 }
859861 }
860862 // Now check against the previous active set and perform banning if this fails
861- ProcessPendingInstantSendLocks (llmq_params, dkgInterval, pend, true );
863+ ProcessPendingInstantSendLocks (llmq_params, peerman, dkgInterval, pend, true );
862864 }
863865
864866 return fMoreWork ;
865867}
866868
867- std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPendingInstantSendLocks (const Consensus::LLMQParams& llmq_params, int signOffset, const std::unordered_map<uint256, std::pair<NodeId, CInstantSendLockPtr>, StaticSaltedHasher>& pend, bool ban)
869+ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPendingInstantSendLocks (
870+ const Consensus::LLMQParams& llmq_params, PeerManager& peerman, int signOffset,
871+ const std::unordered_map<uint256, std::pair<NodeId, CInstantSendLockPtr>, StaticSaltedHasher>& pend, bool ban)
868872{
869873 CBLSBatchVerifier<NodeId, uint256> batchVerifier (false , true , 8 );
870874 std::unordered_map<uint256, CRecoveredSig, StaticSaltedHasher> recSigs;
@@ -936,7 +940,7 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
936940 for (const auto & nodeId : batchVerifier.badSources ) {
937941 // Let's not be too harsh, as the peer might simply be unlucky and might have sent us an old lock which
938942 // does not validate anymore due to changed quorums
939- Assert (m_peerman)-> Misbehaving (nodeId, 20 );
943+ peerman. Misbehaving (nodeId, 20 );
940944 }
941945 }
942946 for (const auto & p : pend) {
@@ -951,7 +955,7 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
951955 continue ;
952956 }
953957
954- ProcessInstantSendLock (nodeId, hash, islock);
958+ ProcessInstantSendLock (nodeId, peerman, hash, islock);
955959
956960 // See comment further on top. We pass a reconstructed recovered sig to the signing manager to avoid
957961 // double-verification of the sig.
@@ -969,7 +973,8 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
969973 return badISLocks;
970974}
971975
972- void CInstantSendManager::ProcessInstantSendLock (NodeId from, const uint256& hash, const CInstantSendLockPtr& islock)
976+ void CInstantSendManager::ProcessInstantSendLock (NodeId from, PeerManager& peerman, const uint256& hash,
977+ const CInstantSendLockPtr& islock)
973978{
974979 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: processing islock, peer=%d\n " , __func__,
975980 islock->txid .ToString (), hash.ToString (), from);
@@ -1030,28 +1035,28 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, const uint256& has
10301035
10311036 CInv inv (MSG_ISDLOCK, hash);
10321037 if (tx != nullptr ) {
1033- Assert (m_peerman)-> RelayInvFiltered (inv, *tx, ISDLOCK_PROTO_VERSION);
1038+ peerman. RelayInvFiltered (inv, *tx, ISDLOCK_PROTO_VERSION);
10341039 } else {
10351040 // we don't have the TX yet, so we only filter based on txid. Later when that TX arrives, we will re-announce
10361041 // with the TX taken into account.
1037- Assert (m_peerman)-> RelayInvFiltered (inv, islock->txid , ISDLOCK_PROTO_VERSION);
1042+ peerman. RelayInvFiltered (inv, islock->txid , ISDLOCK_PROTO_VERSION);
10381043 }
10391044
10401045 ResolveBlockConflicts (hash, *islock);
10411046
10421047 if (tx != nullptr ) {
1043- RemoveMempoolConflictsForLock (hash, *islock);
1048+ RemoveMempoolConflictsForLock (peerman, hash, *islock);
10441049 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- notify about lock %s for tx %s\n " , __func__,
10451050 hash.ToString (), tx->GetHash ().ToString ());
10461051 GetMainSignals ().NotifyTransactionLock (tx, islock);
10471052 // bump mempool counter to make sure newly locked txes are picked up by getblocktemplate
10481053 mempool.AddTransactionsUpdated (1 );
10491054 } else {
1050- m_peerman-> AskPeersForTransaction (islock->txid , m_is_masternode);
1055+ peerman. AskPeersForTransaction (islock->txid , m_is_masternode);
10511056 }
10521057}
10531058
1054- void CInstantSendManager::TransactionAddedToMempool (const CTransactionRef& tx)
1059+ void CInstantSendManager::TransactionAddedToMempool (PeerManager& peerman, const CTransactionRef& tx)
10551060{
10561061 if (!IsInstantSendEnabled () || !m_mn_sync.IsBlockchainSynced () || tx->vin .empty ()) {
10571062 return ;
@@ -1080,7 +1085,7 @@ void CInstantSendManager::TransactionAddedToMempool(const CTransactionRef& tx)
10801085 // TX is not locked, so make sure it is tracked
10811086 AddNonLockedTx (tx, nullptr );
10821087 } else {
1083- RemoveMempoolConflictsForLock (::SerializeHash (*islock), *islock);
1088+ RemoveMempoolConflictsForLock (peerman, ::SerializeHash (*islock), *islock);
10841089 }
10851090}
10861091
@@ -1292,7 +1297,8 @@ void CInstantSendManager::HandleFullyConfirmedBlock(const CBlockIndex* pindex)
12921297 }
12931298}
12941299
1295- void CInstantSendManager::RemoveMempoolConflictsForLock (const uint256& hash, const CInstantSendLock& islock)
1300+ void CInstantSendManager::RemoveMempoolConflictsForLock (PeerManager& peerman, const uint256& hash,
1301+ const CInstantSendLock& islock)
12961302{
12971303 std::unordered_map<uint256, CTransactionRef, StaticSaltedHasher> toDelete;
12981304
@@ -1321,7 +1327,7 @@ void CInstantSendManager::RemoveMempoolConflictsForLock(const uint256& hash, con
13211327 for (const auto & p : toDelete) {
13221328 RemoveConflictedTx (*p.second );
13231329 }
1324- m_peerman-> AskPeersForTransaction (islock.txid , m_is_masternode);
1330+ peerman. AskPeersForTransaction (islock.txid , m_is_masternode);
13251331 }
13261332}
13271333
@@ -1583,10 +1589,10 @@ size_t CInstantSendManager::GetInstantSendLockCount() const
15831589 return db.GetInstantSendLockCount ();
15841590}
15851591
1586- void CInstantSendManager::WorkThreadMain ()
1592+ void CInstantSendManager::WorkThreadMain (PeerManager& peerman )
15871593{
15881594 while (!workInterrupt) {
1589- bool fMoreWork = ProcessPendingInstantSendLocks ();
1595+ bool fMoreWork = ProcessPendingInstantSendLocks (peerman );
15901596 ProcessPendingRetryLockTxs ();
15911597
15921598 if (!fMoreWork && !workInterrupt.sleep_for (std::chrono::milliseconds (100 ))) {
0 commit comments