From 257568eab5baba07571fe2c68759e843d215d4a9 Mon Sep 17 00:00:00 2001 From: glozow Date: Tue, 16 Apr 2024 16:35:07 +0100 Subject: [PATCH] [refactor] move invalid package processing to TxDownload --- src/net_processing.cpp | 2 +- src/node/txdownloadman.h | 3 +++ src/node/txdownloadman_impl.cpp | 9 +++++++++ src/node/txdownloadman_impl.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 5ce7317ab50..8d6b13fe608 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3029,7 +3029,7 @@ void PeerManagerImpl::ProcessPackageResult(const node::PackageToValidate& packag const auto& senders = package_to_validate.m_senders; if (package_result.m_state.IsInvalid()) { - RecentRejectsReconsiderableFilter().insert(GetPackageHash(package)); + m_txdownloadman.MempoolRejectedPackage(package); } // We currently only expect to process 1-parent-1-child packages. Remove if this changes. if (!Assume(package.size() == 2)) return; diff --git a/src/node/txdownloadman.h b/src/node/txdownloadman.h index 5b797f5d9b1..514e1064101 100644 --- a/src/node/txdownloadman.h +++ b/src/node/txdownloadman.h @@ -168,6 +168,9 @@ public: /** Respond to transaction rejected from mempool */ RejectedTxTodo MempoolRejectedTx(const CTransactionRef& ptx, const TxValidationState& state, NodeId nodeid, bool first_time_failure); + + /** Respond to package rejected from mempool */ + void MempoolRejectedPackage(const Package& package); }; } // namespace node #endif // BITCOIN_NODE_TXDOWNLOADMAN_H diff --git a/src/node/txdownloadman_impl.cpp b/src/node/txdownloadman_impl.cpp index 13000dc5755..4d5bfad68c1 100644 --- a/src/node/txdownloadman_impl.cpp +++ b/src/node/txdownloadman_impl.cpp @@ -79,6 +79,10 @@ RejectedTxTodo TxDownloadManager::MempoolRejectedTx(const CTransactionRef& ptx, { return m_impl->MempoolRejectedTx(ptx, state, nodeid, first_time_failure); } +void TxDownloadManager::MempoolRejectedPackage(const Package& package) +{ + m_impl->MempoolRejectedPackage(package); +} // TxDownloadManagerImpl void TxDownloadManagerImpl::ActiveTipChange() @@ -441,4 +445,9 @@ node::RejectedTxTodo TxDownloadManagerImpl::MempoolRejectedTx(const CTransaction .m_package_to_validate = std::move(package_to_validate) }; } + +void TxDownloadManagerImpl::MempoolRejectedPackage(const Package& package) +{ + RecentRejectsReconsiderableFilter().insert(GetPackageHash(package)); +} } // namespace node diff --git a/src/node/txdownloadman_impl.h b/src/node/txdownloadman_impl.h index 496f2891847..9843c815e18 100644 --- a/src/node/txdownloadman_impl.h +++ b/src/node/txdownloadman_impl.h @@ -166,6 +166,7 @@ public: void MempoolAcceptedTx(const CTransactionRef& tx); RejectedTxTodo MempoolRejectedTx(const CTransactionRef& ptx, const TxValidationState& state, NodeId nodeid, bool first_time_failure); + void MempoolRejectedPackage(const Package& package); }; } // namespace node #endif // BITCOIN_NODE_TXDOWNLOADMAN_IMPL_H