mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(net): add negotiated eth version to events (#1478)
This commit is contained in:
@ -36,7 +36,7 @@ use futures::{Future, StreamExt};
|
||||
use parking_lot::Mutex;
|
||||
use reth_eth_wire::{
|
||||
capability::{Capabilities, CapabilityMessage},
|
||||
DisconnectReason, Status,
|
||||
DisconnectReason, EthVersion, Status,
|
||||
};
|
||||
use reth_net_common::bandwidth_meter::BandwidthMeter;
|
||||
use reth_network_api::{EthProtocolInfo, NetworkStatus, ReputationChangeKind};
|
||||
@ -632,6 +632,7 @@ where
|
||||
peer_id,
|
||||
remote_addr,
|
||||
capabilities,
|
||||
version,
|
||||
messages,
|
||||
status,
|
||||
direction,
|
||||
@ -656,6 +657,7 @@ where
|
||||
this.event_listeners.send(NetworkEvent::SessionEstablished {
|
||||
peer_id,
|
||||
capabilities,
|
||||
version,
|
||||
status,
|
||||
messages,
|
||||
});
|
||||
@ -843,6 +845,8 @@ pub enum NetworkEvent {
|
||||
messages: PeerRequestSender,
|
||||
/// The status of the peer to which a session was established.
|
||||
status: Status,
|
||||
/// negotiated eth version of the session
|
||||
version: EthVersion,
|
||||
},
|
||||
/// Event emitted when a new peer is added
|
||||
PeerAdded(PeerId),
|
||||
|
||||
@ -7,7 +7,7 @@ use reth_ecies::{stream::ECIESStream, ECIESError};
|
||||
use reth_eth_wire::{
|
||||
capability::{Capabilities, CapabilityMessage},
|
||||
errors::EthStreamError,
|
||||
DisconnectReason, EthStream, P2PStream, Status,
|
||||
DisconnectReason, EthStream, EthVersion, P2PStream, Status,
|
||||
};
|
||||
use reth_net_common::bandwidth_meter::MeteredStream;
|
||||
use reth_primitives::PeerId;
|
||||
@ -51,6 +51,8 @@ pub(crate) struct ActiveSessionHandle {
|
||||
pub(crate) direction: Direction,
|
||||
/// The assigned id for this session
|
||||
pub(crate) session_id: SessionId,
|
||||
/// negotiated eth version
|
||||
pub(crate) version: EthVersion,
|
||||
/// The identifier of the remote peer
|
||||
pub(crate) remote_id: PeerId,
|
||||
/// The timestamp when the session has been established.
|
||||
|
||||
@ -17,7 +17,7 @@ use reth_ecies::{stream::ECIESStream, ECIESError};
|
||||
use reth_eth_wire::{
|
||||
capability::{Capabilities, CapabilityMessage},
|
||||
errors::EthStreamError,
|
||||
DisconnectReason, HelloMessage, Status, UnauthedEthStream, UnauthedP2PStream,
|
||||
DisconnectReason, EthVersion, HelloMessage, Status, UnauthedEthStream, UnauthedP2PStream,
|
||||
};
|
||||
use reth_metrics_common::metered_sender::MeteredSender;
|
||||
use reth_net_common::{
|
||||
@ -434,6 +434,9 @@ impl SessionManager {
|
||||
self.initial_internal_request_timeout.as_millis() as u64,
|
||||
));
|
||||
|
||||
// negotiated version
|
||||
let version = conn.version();
|
||||
|
||||
let session = ActiveSession {
|
||||
next_id: 0,
|
||||
remote_peer_id: peer_id,
|
||||
@ -461,6 +464,7 @@ impl SessionManager {
|
||||
direction,
|
||||
session_id,
|
||||
remote_id: peer_id,
|
||||
version,
|
||||
established: Instant::now(),
|
||||
capabilities: Arc::clone(&capabilities),
|
||||
commands_to_session,
|
||||
@ -474,6 +478,7 @@ impl SessionManager {
|
||||
Poll::Ready(SessionEvent::SessionEstablished {
|
||||
peer_id,
|
||||
remote_addr,
|
||||
version,
|
||||
capabilities,
|
||||
status,
|
||||
messages,
|
||||
@ -590,6 +595,8 @@ pub(crate) enum SessionEvent {
|
||||
peer_id: PeerId,
|
||||
remote_addr: SocketAddr,
|
||||
capabilities: Arc<Capabilities>,
|
||||
/// negotiated eth version
|
||||
version: EthVersion,
|
||||
status: Status,
|
||||
messages: PeerRequestSender,
|
||||
direction: Direction,
|
||||
|
||||
@ -9,7 +9,7 @@ use futures::Stream;
|
||||
use reth_eth_wire::{
|
||||
capability::{Capabilities, CapabilityMessage},
|
||||
errors::EthStreamError,
|
||||
DisconnectReason, Status,
|
||||
DisconnectReason, EthVersion, Status,
|
||||
};
|
||||
use reth_primitives::PeerId;
|
||||
use reth_provider::BlockProvider;
|
||||
@ -126,6 +126,7 @@ where
|
||||
peer_id,
|
||||
remote_addr,
|
||||
capabilities,
|
||||
version,
|
||||
status,
|
||||
messages,
|
||||
direction,
|
||||
@ -142,6 +143,7 @@ where
|
||||
peer_id,
|
||||
remote_addr,
|
||||
capabilities,
|
||||
version,
|
||||
messages,
|
||||
status,
|
||||
direction,
|
||||
@ -389,6 +391,8 @@ pub(crate) enum SwarmEvent {
|
||||
peer_id: PeerId,
|
||||
remote_addr: SocketAddr,
|
||||
capabilities: Arc<Capabilities>,
|
||||
/// negotiated eth version
|
||||
version: EthVersion,
|
||||
messages: PeerRequestSender,
|
||||
status: Status,
|
||||
direction: Direction,
|
||||
|
||||
Reference in New Issue
Block a user