Skip to content

Commit 2b482dc

Browse files
committed
[refactor] have ProcessPackageResult take a PackageToValidate
1 parent c2ada05 commit 2b482dc

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/net_processing.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -600,14 +600,6 @@ class PeerManagerImpl final : public PeerManager
600600
void ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, const std::list<CTransactionRef>& replaced_transactions)
601601
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
602602

603-
/** Handle the results of package validation: calls ProcessValidTx and ProcessInvalidTx for
604-
* individual transactions, and caches rejection for the package as a group.
605-
* @param[in] senders Must contain the nodeids of the peers that provided each transaction
606-
* in package, in the same order.
607-
* */
608-
void ProcessPackageResult(const Package& package, const PackageMempoolAcceptResult& package_result, const std::vector<NodeId>& senders)
609-
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
610-
611603
struct PackageToValidate {
612604
const Package m_txns;
613605
const std::vector<NodeId> m_senders;
@@ -632,6 +624,12 @@ class PeerManagerImpl final : public PeerManager
632624
}
633625
};
634626

627+
/** Handle the results of package validation: calls ProcessValidTx and ProcessInvalidTx for
628+
* individual transactions, and caches rejection for the package as a group.
629+
*/
630+
void ProcessPackageResult(const PackageToValidate& package_to_validate, const PackageMempoolAcceptResult& package_result)
631+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
632+
635633
/** Look for a child of this transaction in the orphanage to form a 1-parent-1-child package,
636634
* skipping any combinations that have already been tried. Return the resulting package along with
637635
* the senders of its respective transactions, or std::nullopt if no package is found. */
@@ -3251,12 +3249,15 @@ void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, c
32513249
}
32523250
}
32533251

3254-
void PeerManagerImpl::ProcessPackageResult(const Package& package, const PackageMempoolAcceptResult& package_result, const std::vector<NodeId>& senders)
3252+
void PeerManagerImpl::ProcessPackageResult(const PackageToValidate& package_to_validate, const PackageMempoolAcceptResult& package_result)
32553253
{
32563254
AssertLockNotHeld(m_peer_mutex);
32573255
AssertLockHeld(g_msgproc_mutex);
32583256
AssertLockHeld(cs_main);
32593257

3258+
const auto& package = package_to_validate.m_txns;
3259+
const auto& senders = package_to_validate.m_senders;
3260+
32603261
if (package_result.m_state.IsInvalid()) {
32613262
m_recent_rejects_reconsiderable.insert(GetPackageHash(package));
32623263
}
@@ -4548,7 +4549,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
45484549
const auto package_result{ProcessNewPackage(m_chainman.ActiveChainstate(), m_mempool, package_to_validate->m_txns, /*test_accept=*/false, /*client_maxfeerate=*/std::nullopt)};
45494550
LogDebug(BCLog::TXPACKAGES, "package evaluation for %s: %s\n", package_to_validate->ToString(),
45504551
package_result.m_state.IsValid() ? "package accepted" : "package rejected");
4551-
ProcessPackageResult(package_to_validate->m_txns, package_result, package_to_validate->m_senders);
4552+
ProcessPackageResult(package_to_validate.value(), package_result);
45524553
}
45534554
}
45544555
// If a tx is detected by m_recent_rejects it is ignored. Because we haven't
@@ -4663,7 +4664,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
46634664
const auto package_result{ProcessNewPackage(m_chainman.ActiveChainstate(), m_mempool, package_to_validate->m_txns, /*test_accept=*/false, /*client_maxfeerate=*/std::nullopt)};
46644665
LogDebug(BCLog::TXPACKAGES, "package evaluation for %s: %s\n", package_to_validate->ToString(),
46654666
package_result.m_state.IsValid() ? "package accepted" : "package rejected");
4666-
ProcessPackageResult(package_to_validate->m_txns, package_result, package_to_validate->m_senders);
4667+
ProcessPackageResult(package_to_validate.value(), package_result);
46674668
}
46684669
}
46694670

0 commit comments

Comments
 (0)