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