@@ -18,6 +18,8 @@ use cuprate_dandelion_tower::{
18
18
State , TxState ,
19
19
} ;
20
20
use cuprate_helper:: asynch:: rayon_spawn_async;
21
+ use cuprate_p2p:: NetworkInterface ;
22
+ use cuprate_p2p_core:: ClearNet ;
21
23
use cuprate_txpool:: {
22
24
service:: {
23
25
interface:: {
@@ -34,7 +36,10 @@ use crate::{
34
36
constants:: PANIC_CRITICAL_SERVICE_ERROR ,
35
37
p2p:: CrossNetworkInternalPeerId ,
36
38
signals:: REORG_LOCK ,
37
- txpool:: txs_being_handled:: { TxsBeingHandled , TxsBeingHandledLocally } ,
39
+ txpool:: {
40
+ dandelion,
41
+ txs_being_handled:: { TxsBeingHandled , TxsBeingHandledLocally } ,
42
+ } ,
38
43
} ;
39
44
40
45
/// An error that can happen handling an incoming tx.
@@ -78,6 +83,35 @@ pub struct IncomingTxHandler {
78
83
pub ( super ) txpool_read_handle : TxpoolReadHandle ,
79
84
}
80
85
86
+ impl IncomingTxHandler {
87
+ /// Initialize the [`IncomingTxHandler`].
88
+ #[ expect( clippy:: significant_drop_tightening) ]
89
+ pub fn init (
90
+ clear_net : NetworkInterface < ClearNet > ,
91
+ txpool_write_handle : TxpoolWriteHandle ,
92
+ txpool_read_handle : TxpoolReadHandle ,
93
+ blockchain_context_cache : BlockChainContextService ,
94
+ tx_verifier_service : ConcreteTxVerifierService ,
95
+ ) -> Self {
96
+ let dandelion_router = dandelion:: dandelion_router ( clear_net) ;
97
+
98
+ let dandelion_pool_manager = dandelion:: start_dandelion_pool_manager (
99
+ dandelion_router,
100
+ txpool_read_handle. clone ( ) ,
101
+ txpool_write_handle. clone ( ) ,
102
+ ) ;
103
+
104
+ Self {
105
+ txs_being_handled : TxsBeingHandled :: new ( ) ,
106
+ blockchain_context_cache,
107
+ dandelion_pool_manager,
108
+ tx_verifier_service,
109
+ txpool_write_handle,
110
+ txpool_read_handle,
111
+ }
112
+ }
113
+ }
114
+
81
115
impl Service < IncomingTxs > for IncomingTxHandler {
82
116
type Response = ( ) ;
83
117
type Error = IncomingTxError ;
@@ -89,8 +123,7 @@ impl Service<IncomingTxs> for IncomingTxHandler {
89
123
90
124
fn call ( & mut self , req : IncomingTxs ) -> Self :: Future {
91
125
handle_incoming_txs (
92
- req. txs ,
93
- req. state ,
126
+ req,
94
127
self . txs_being_handled . clone ( ) ,
95
128
self . blockchain_context_cache . clone ( ) ,
96
129
self . tx_verifier_service . clone ( ) ,
@@ -105,8 +138,7 @@ impl Service<IncomingTxs> for IncomingTxHandler {
105
138
/// Handles the incoming txs.
106
139
#[ expect( clippy:: too_many_arguments) ]
107
140
async fn handle_incoming_txs (
108
- txs : Vec < Bytes > ,
109
- state : TxState < CrossNetworkInternalPeerId > ,
141
+ IncomingTxs { txs, state } : IncomingTxs ,
110
142
txs_being_handled : TxsBeingHandled ,
111
143
mut blockchain_context_cache : BlockChainContextService ,
112
144
mut tx_verifier_service : ConcreteTxVerifierService ,
@@ -197,7 +229,7 @@ async fn prepare_incoming_txs(
197
229
let txs = tx_blobs
198
230
. into_iter ( )
199
231
. filter_map ( |tx_blob| {
200
- let tx_blob_hash = transaction_blob_hash ( tx_blob. as_ref ( ) ) ;
232
+ let tx_blob_hash = transaction_blob_hash ( & tx_blob) ;
201
233
202
234
// If a duplicate is in here the incoming tx batch contained the same tx twice.
203
235
if !tx_blob_hashes. insert ( tx_blob_hash) {
0 commit comments