diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 5463b20f7f37..b352dfe31366 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -1005,51 +1005,9 @@ where let _ = response.send(Ok(resp)); } } -} - -impl TransactionsManager -where - Pool: TransactionPool + 'static, - Pool::Transaction: - PoolTransaction>, -{ - /// Handles dedicated transaction events related to the `eth` protocol. - fn on_network_tx_event(&mut self, event: NetworkTransactionEvent) { - match event { - NetworkTransactionEvent::IncomingTransactions { peer_id, msg } => { - // ensure we didn't receive any blob transactions as these are disallowed to be - // broadcasted in full - - let has_blob_txs = msg.has_eip4844(); - - let non_blob_txs = msg - .0 - .into_iter() - .map(PooledTransactionsElement::try_from_broadcast) - .filter_map(Result::ok) - .collect(); - - self.import_transactions(peer_id, non_blob_txs, TransactionSource::Broadcast); - - if has_blob_txs { - debug!(target: "net::tx", ?peer_id, "received bad full blob transaction broadcast"); - self.report_peer_bad_transactions(peer_id); - } - } - NetworkTransactionEvent::IncomingPooledTransactionHashes { peer_id, msg } => { - self.on_new_pooled_transaction_hashes(peer_id, msg) - } - NetworkTransactionEvent::GetPooledTransactions { peer_id, request, response } => { - self.on_get_pooled_transactions(peer_id, request, response) - } - NetworkTransactionEvent::GetTransactionsHandle(response) => { - let _ = response.send(Some(self.handle())); - } - } - } /// Handles a command received from a detached [`TransactionsHandle`] - fn on_command(&mut self, cmd: TransactionsCommand) { + fn on_command(&mut self, cmd: TransactionsCommand) { match cmd { TransactionsCommand::PropagateHash(hash) => { self.on_new_pending_transactions(vec![hash]) @@ -1089,7 +1047,7 @@ where } /// Handles a received event related to common network events. - fn on_network_event(&mut self, event_result: NetworkEvent) { + fn on_network_event(&mut self, event_result: NetworkEvent>) { match event_result { NetworkEvent::SessionClosed { peer_id, .. } => { // remove the peer @@ -1141,6 +1099,48 @@ where _ => {} } } +} + +impl TransactionsManager +where + Pool: TransactionPool + 'static, + Pool::Transaction: + PoolTransaction>, +{ + /// Handles dedicated transaction events related to the `eth` protocol. + fn on_network_tx_event(&mut self, event: NetworkTransactionEvent) { + match event { + NetworkTransactionEvent::IncomingTransactions { peer_id, msg } => { + // ensure we didn't receive any blob transactions as these are disallowed to be + // broadcasted in full + + let has_blob_txs = msg.has_eip4844(); + + let non_blob_txs = msg + .0 + .into_iter() + .map(PooledTransactionsElement::try_from_broadcast) + .filter_map(Result::ok) + .collect(); + + self.import_transactions(peer_id, non_blob_txs, TransactionSource::Broadcast); + + if has_blob_txs { + debug!(target: "net::tx", ?peer_id, "received bad full blob transaction broadcast"); + self.report_peer_bad_transactions(peer_id); + } + } + NetworkTransactionEvent::IncomingPooledTransactionHashes { peer_id, msg } => { + self.on_new_pooled_transaction_hashes(peer_id, msg) + } + NetworkTransactionEvent::GetPooledTransactions { peer_id, request, response } => { + self.on_get_pooled_transactions(peer_id, request, response) + } + NetworkTransactionEvent::GetTransactionsHandle(response) => { + let _ = response.send(Some(self.handle())); + } + } + } /// Starts the import process for the given transactions. fn import_transactions(