feat: use broadcast tx generic (#12733)

This commit is contained in:
Matthias Seitz
2024-11-21 11:14:31 +01:00
committed by GitHub
parent 33730536f5
commit 1b874dcc6c
4 changed files with 11 additions and 8 deletions

View File

@ -182,7 +182,11 @@ pub enum EthMessage<N: NetworkPrimitives = EthNetworkPrimitives> {
)]
NewBlock(Box<NewBlock<N::Block>>),
/// Represents a Transactions message broadcast to the network.
Transactions(Transactions),
#[cfg_attr(
feature = "serde",
serde(bound = "N::BroadcastedTransaction: serde::Serialize + serde::de::DeserializeOwned")
)]
Transactions(Transactions<N::BroadcastedTransaction>),
/// Represents a `NewPooledTransactionHashes` message for eth/66 version.
NewPooledTransactionHashes66(NewPooledTransactionHashes66),
/// Represents a `NewPooledTransactionHashes` message for eth/68 version.
@ -302,7 +306,7 @@ pub enum EthBroadcastMessage<N: NetworkPrimitives = EthNetworkPrimitives> {
/// Represents a new block broadcast message.
NewBlock(Arc<NewBlock<N::Block>>),
/// Represents a transactions broadcast message.
Transactions(SharedTransactions),
Transactions(SharedTransactions<N::BroadcastedTransaction>),
}
// === impl EthBroadcastMessage ===

View File

@ -48,9 +48,9 @@ pub enum PeerMessage<N: NetworkPrimitives = EthNetworkPrimitives> {
/// Broadcast new block.
NewBlock(NewBlockMessage<N::Block>),
/// Received transactions _from_ the peer
ReceivedTransaction(Transactions),
ReceivedTransaction(Transactions<N::BroadcastedTransaction>),
/// Broadcast transactions _from_ local _to_ a peer.
SendTransactions(SharedTransactions),
SendTransactions(SharedTransactions<N::BroadcastedTransaction>),
/// Send new pooled transactions
PooledTransactions(NewPooledTransactionHashes),
/// All `eth` request variants.

View File

@ -21,7 +21,6 @@ use reth_network_api::{
use reth_network_p2p::sync::{NetworkSyncUpdater, SyncState, SyncStateProvider};
use reth_network_peers::{NodeRecord, PeerId};
use reth_network_types::{PeerAddr, PeerKind, Reputation, ReputationChangeKind};
use reth_primitives::TransactionSigned;
use reth_tokio_util::{EventSender, EventStream};
use secp256k1::SecretKey;
use std::{
@ -130,7 +129,7 @@ impl<N: NetworkPrimitives> NetworkHandle<N> {
}
/// Send full transactions to the peer
pub fn send_transactions(&self, peer_id: PeerId, msg: Vec<Arc<TransactionSigned>>) {
pub fn send_transactions(&self, peer_id: PeerId, msg: Vec<Arc<N::BroadcastedTransaction>>) {
self.send_message(NetworkHandleMessage::SendTransaction {
peer_id,
msg: SharedTransactions(msg),
@ -466,7 +465,7 @@ pub(crate) enum NetworkHandleMessage<N: NetworkPrimitives = EthNetworkPrimitives
/// The ID of the peer to which the transactions are sent.
peer_id: PeerId,
/// The shared transactions to send.
msg: SharedTransactions,
msg: SharedTransactions<N::BroadcastedTransaction>,
},
/// Sends a list of transaction hashes to the given peer.
SendPooledTransactionHashes {

View File

@ -1768,7 +1768,7 @@ pub enum NetworkTransactionEvent<N: NetworkPrimitives = EthNetworkPrimitives> {
/// The ID of the peer from which the transactions were received.
peer_id: PeerId,
/// The received transactions.
msg: Transactions,
msg: Transactions<N::BroadcastedTransaction>,
},
/// Represents the event of receiving a list of transaction hashes from a peer.
IncomingPooledTransactionHashes {