chore: track client version in tx peer (#2452)

This commit is contained in:
Matthias Seitz
2023-04-28 20:53:42 +02:00
committed by GitHub
parent 70ead6e6dd
commit 433ecdcaec
5 changed files with 16 additions and 9 deletions

View File

@ -656,7 +656,7 @@ where
info!(
target : "net",
?remote_addr,
client_version,
%client_version,
?peer_id,
?total_active,
"Session established"
@ -884,7 +884,7 @@ pub enum NetworkEvent {
/// The remote addr of the peer to which a session was established.
remote_addr: SocketAddr,
/// The client version of the peer to which a session was established.
client_version: String,
client_version: Arc<String>,
/// Capabilities the peer announced
capabilities: Arc<Capabilities>,
/// A request channel to the session task.

View File

@ -62,7 +62,7 @@ pub(crate) struct ActiveSessionHandle {
/// Sender half of the command channel used send commands _to_ the spawned session
pub(crate) commands_to_session: mpsc::Sender<SessionCommand>,
/// The client's name and version
pub(crate) client_version: String,
pub(crate) client_version: Arc<String>,
/// The address we're connected to
pub(crate) remote_addr: SocketAddr,
}
@ -85,7 +85,7 @@ pub struct PeerInfo {
/// The identifier of the remote peer
pub remote_id: PeerId,
/// The client's name and version
pub client_version: String,
pub client_version: Arc<String>,
/// The address we're connected to
pub remote_addr: SocketAddr,
/// The direction of the session

View File

@ -457,6 +457,7 @@ impl SessionManager {
self.spawn(session);
let client_version = Arc::new(client_id);
let handle = ActiveSessionHandle {
direction,
session_id,
@ -465,7 +466,7 @@ impl SessionManager {
established: Instant::now(),
capabilities: Arc::clone(&capabilities),
commands_to_session,
client_version: client_id.clone(),
client_version: Arc::clone(&client_version),
remote_addr,
};
@ -475,7 +476,7 @@ impl SessionManager {
Poll::Ready(SessionEvent::SessionEstablished {
peer_id,
remote_addr,
client_version: client_id,
client_version,
version,
capabilities,
status,
@ -592,7 +593,7 @@ pub(crate) enum SessionEvent {
SessionEstablished {
peer_id: PeerId,
remote_addr: SocketAddr,
client_version: String,
client_version: Arc<String>,
capabilities: Arc<Capabilities>,
/// negotiated eth version
version: EthVersion,

View File

@ -393,7 +393,7 @@ pub(crate) enum SwarmEvent {
SessionEstablished {
peer_id: PeerId,
remote_addr: SocketAddr,
client_version: String,
client_version: Arc<String>,
capabilities: Arc<Capabilities>,
/// negotiated eth version
version: EthVersion,

View File

@ -349,7 +349,9 @@ where
// remove the peer
self.peers.remove(&peer_id);
}
NetworkEvent::SessionEstablished { peer_id, messages, version, .. } => {
NetworkEvent::SessionEstablished {
peer_id, client_version, messages, version, ..
} => {
// insert a new peer into the peerset
self.peers.insert(
peer_id,
@ -359,6 +361,7 @@ where
),
request_tx: messages,
version,
client_version,
},
);
@ -685,6 +688,9 @@ struct Peer {
request_tx: PeerRequestSender,
/// negotiated version of the session.
version: EthVersion,
/// The peer's client version.
#[allow(unused)]
client_version: Arc<String>,
}
/// Commands to send to the [`TransactionsManager`](crate::transactions::TransactionsManager)