mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: introduce EthMessage variant to NetworkHandleMessage (#13033)
This commit is contained in:
@ -644,6 +644,9 @@ impl<N: NetworkPrimitives> NetworkManager<N> {
|
||||
let _ = tx.send(None);
|
||||
}
|
||||
}
|
||||
NetworkHandleMessage::EthMessage { peer_id, message } => {
|
||||
self.swarm.sessions_mut().send_message(&peer_id, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
config::NetworkMode, protocol::RlpxSubProtocol, swarm::NetworkConnectionState,
|
||||
transactions::TransactionsHandle, FetchClient,
|
||||
config::NetworkMode, message::PeerMessage, protocol::RlpxSubProtocol,
|
||||
swarm::NetworkConnectionState, transactions::TransactionsHandle, FetchClient,
|
||||
};
|
||||
use alloy_primitives::B256;
|
||||
use enr::Enr;
|
||||
@ -136,6 +136,11 @@ impl<N: NetworkPrimitives> NetworkHandle<N> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Send eth message to the peer.
|
||||
pub fn send_eth_message(&self, peer_id: PeerId, message: PeerMessage<N>) {
|
||||
self.send_message(NetworkHandleMessage::EthMessage { peer_id, message })
|
||||
}
|
||||
|
||||
/// Send message to get the [`TransactionsHandle`].
|
||||
///
|
||||
/// Returns `None` if no transaction task is installed.
|
||||
@ -481,6 +486,13 @@ pub(crate) enum NetworkHandleMessage<N: NetworkPrimitives = EthNetworkPrimitives
|
||||
/// The request to send to the peer's sessions.
|
||||
request: PeerRequest<N>,
|
||||
},
|
||||
/// Sends an `eth` protocol message to the peer.
|
||||
EthMessage {
|
||||
/// The peer to send the message to.
|
||||
peer_id: PeerId,
|
||||
/// The message to send to the peer's sessions.
|
||||
message: PeerMessage<N>,
|
||||
},
|
||||
/// Applies a reputation change to the given peer.
|
||||
ReputationChange(PeerId, ReputationChangeKind),
|
||||
/// Returns the client that can be used to interact with the network.
|
||||
|
||||
Reference in New Issue
Block a user