From dee0b8c055db3d1fbbb5cf3a98f2476117c118be Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 26 Nov 2024 15:23:27 +0100 Subject: [PATCH] feat: relax constraints for on_get_pooled_txs (#12880) --- crates/net/network/src/transactions/mod.rs | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 6e0a3b2f32..227e812fc7 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -681,9 +681,13 @@ where impl TransactionsManager where Pool: TransactionPool, - N: NetworkPrimitives, + N: NetworkPrimitives< + BroadcastedTransaction: SignedTransaction, + PooledTransaction: SignedTransaction, + >, <::Transaction as PoolTransaction>::Consensus: Into, + <::Transaction as PoolTransaction>::Pooled: Into, { /// Invoked when transactions in the local mempool are considered __pending__. /// @@ -955,28 +959,20 @@ where // notify pool so events get fired self.pool.on_propagated(propagated); } -} -impl TransactionsManager -where - Pool: TransactionPool + 'static, - <::Transaction as PoolTransaction>::Consensus: Into, - <::Transaction as PoolTransaction>::Pooled: - Into, -{ /// Request handler for an incoming request for transactions fn on_get_pooled_transactions( &mut self, peer_id: PeerId, request: GetPooledTransactions, - response: oneshot::Sender>, + response: oneshot::Sender>>, ) { if let Some(peer) = self.peers.get_mut(&peer_id) { if self.network.tx_gossip_disabled() { let _ = response.send(Ok(PooledTransactions::default())); return } - let transactions = self.pool.get_pooled_transactions_as::( + let transactions = self.pool.get_pooled_transactions_as::( request.0, GetPooledTransactionLimit::ResponseSizeSoftLimit( self.transaction_fetcher.info.soft_limit_byte_size_pooled_transactions_response, @@ -987,13 +983,21 @@ where // we sent a response at which point we assume that the peer is aware of the // transactions - peer.seen_transactions.extend(transactions.iter().map(|tx| *tx.hash())); + peer.seen_transactions.extend(transactions.iter().map(|tx| *tx.tx_hash())); let resp = PooledTransactions(transactions); let _ = response.send(Ok(resp)); } } +} +impl TransactionsManager +where + Pool: TransactionPool + 'static, + <::Transaction as PoolTransaction>::Consensus: Into, + <::Transaction as PoolTransaction>::Pooled: + Into, +{ /// Handles dedicated transaction events related to the `eth` protocol. fn on_network_tx_event(&mut self, event: NetworkTransactionEvent) { match event {