@@ -172,7 +172,7 @@ MessageProcessingResult CInstantSendManager::ProcessMessageInstantSendLock(const
172172 return ret;
173173}
174174
175- bool CInstantSendManager::ProcessPendingInstantSendLocks (PeerManager& peerman )
175+ bool CInstantSendManager::ProcessPendingInstantSendLocks (std::vector<std::pair<NodeId, MessageProcessingResult>>& peer_activity )
176176{
177177 decltype (pendingInstantSendLocks) pend;
178178 bool fMoreWork {false };
@@ -217,7 +217,7 @@ bool CInstantSendManager::ProcessPendingInstantSendLocks(PeerManager& peerman)
217217 auto dkgInterval = llmq_params.dkgInterval ;
218218
219219 // First check against the current active set and don't ban
220- auto badISLocks = ProcessPendingInstantSendLocks (llmq_params, peerman, /* signOffset=*/ 0 , pend, false );
220+ auto badISLocks = ProcessPendingInstantSendLocks (llmq_params, /* signOffset=*/ 0 , /* ban= */ false , pend, peer_activity );
221221 if (!badISLocks.empty ()) {
222222 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- doing verification on old active set\n " , __func__);
223223
@@ -230,16 +230,16 @@ bool CInstantSendManager::ProcessPendingInstantSendLocks(PeerManager& peerman)
230230 }
231231 }
232232 // Now check against the previous active set and perform banning if this fails
233- ProcessPendingInstantSendLocks (llmq_params, peerman, dkgInterval , pend, true );
233+ ProcessPendingInstantSendLocks (llmq_params, dkgInterval, /* ban= */ true , pend, peer_activity );
234234 }
235235
236236 return fMoreWork ;
237237}
238238
239239std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPendingInstantSendLocks (
240- const Consensus::LLMQParams& llmq_params, PeerManager& peerman, int signOffset ,
240+ const Consensus::LLMQParams& llmq_params, int signOffset, bool ban ,
241241 const std::unordered_map<uint256, std::pair<NodeId, instantsend::InstantSendLockPtr>, StaticSaltedHasher>& pend,
242- bool ban )
242+ std::vector<std::pair<NodeId, MessageProcessingResult>>& peer_activity )
243243{
244244 CBLSBatchVerifier<NodeId, uint256> batchVerifier (false , true , 8 );
245245 std::unordered_map<uint256, CRecoveredSig, StaticSaltedHasher> recSigs;
@@ -315,7 +315,7 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
315315 for (const auto & nodeId : batchVerifier.badSources ) {
316316 // Let's not be too harsh, as the peer might simply be unlucky and might have sent us an old lock which
317317 // does not validate anymore due to changed quorums
318- peerman. Misbehaving ( nodeId, 20 );
318+ peer_activity. push_back ({ nodeId, MisbehavingError{ 20 }} );
319319 }
320320 }
321321 for (const auto & p : pend) {
@@ -330,7 +330,7 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
330330 continue ;
331331 }
332332
333- ProcessInstantSendLock ( nodeId, peerman , hash, islock);
333+ peer_activity. push_back ({ nodeId, ProcessInstantSendLock (nodeId , hash, islock)} );
334334
335335 // See comment further on top. We pass a reconstructed recovered sig to the signing manager to avoid
336336 // double-verification of the sig.
@@ -348,8 +348,8 @@ std::unordered_set<uint256, StaticSaltedHasher> CInstantSendManager::ProcessPend
348348 return badISLocks;
349349}
350350
351- void CInstantSendManager::ProcessInstantSendLock (NodeId from, PeerManager& peerman , const uint256& hash,
352- const instantsend::InstantSendLockPtr& islock)
351+ MessageProcessingResult CInstantSendManager::ProcessInstantSendLock (NodeId from, const uint256& hash,
352+ const instantsend::InstantSendLockPtr& islock)
353353{
354354 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s, islock=%s: processing islock, peer=%d\n " ,
355355 __func__, islock->txid .ToString (), hash.ToString (), from);
@@ -358,12 +358,12 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, PeerManager& peerm
358358 m_signer->ClearLockFromQueue (islock);
359359 }
360360 if (db.KnownInstantSendLock (hash)) {
361- return ;
361+ return {} ;
362362 }
363363
364364 if (const auto sameTxIsLock = db.GetInstantSendLockByTxid (islock->txid )) {
365365 // can happen, nothing to do
366- return ;
366+ return {} ;
367367 }
368368 for (const auto & in : islock->inputs ) {
369369 const auto sameOutpointIsLock = db.GetInstantSendLockByInput (in);
@@ -386,7 +386,7 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, PeerManager& peerm
386386 if (pindexMined != nullptr && clhandler.HasChainLock (pindexMined->nHeight , pindexMined->GetBlockHash ())) {
387387 LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txlock=%s, islock=%s: dropping islock as it already got a ChainLock in block %s, peer=%d\n " , __func__,
388388 islock->txid .ToString (), hash.ToString (), hashBlock.ToString (), from);
389- return ;
389+ return {} ;
390390 }
391391 }
392392
@@ -417,15 +417,17 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, PeerManager& peerm
417417 mempool.AddTransactionsUpdated (1 );
418418 }
419419
420+ MessageProcessingResult ret{/* is_masternode*/ m_signer != nullptr };
420421 CInv inv (MSG_ISDLOCK, hash);
421422 if (found_transaction) {
422- peerman. RelayInvFiltered (inv, *tx, ISDLOCK_PROTO_VERSION );
423+ ret. m_inv_filter = std::make_pair (inv, tx );
423424 } else {
424425 // we don't have the TX yet, so we only filter based on txid. Later when that TX arrives, we will re-announce
425426 // with the TX taken into account.
426- peerman. RelayInvFiltered (inv, islock->txid , ISDLOCK_PROTO_VERSION );
427- peerman. AskPeersForTransaction ( islock->txid , /* is_masternode= */ m_signer != nullptr ) ;
427+ ret. m_inv_filter = std::make_pair (inv, islock->txid );
428+ ret. m_request_tx = islock->txid ;
428429 }
430+ return ret;
429431}
430432
431433void CInstantSendManager::TransactionAddedToMempool (const CTransactionRef& tx)
@@ -925,7 +927,11 @@ void CInstantSendManager::WorkThreadMain(PeerManager& peerman)
925927 while (!workInterrupt) {
926928 bool fMoreWork = [&]() -> bool {
927929 if (!IsInstantSendEnabled ()) return false ;
928- const bool more_work{ProcessPendingInstantSendLocks (peerman)};
930+ std::vector<std::pair<NodeId, MessageProcessingResult>> peer_activity{};
931+ const bool more_work{ProcessPendingInstantSendLocks (peer_activity)};
932+ for (const auto & [node_id, mpr] : peer_activity) {
933+ peerman.PostProcessMessage (std::move (mpr), node_id);
934+ }
929935 if (!m_signer) return more_work;
930936 // Construct set of non-locked transactions that are pending to retry
931937 std::vector<CTransactionRef> txns{};
0 commit comments