refactor: split NetworkEventListenerProvider (#12972)

This commit is contained in:
Léa Narzis
2024-12-04 19:27:58 +01:00
committed by GitHub
parent 0daa456f3a
commit fbd2d6eeda
15 changed files with 346 additions and 254 deletions

View File

@ -16,6 +16,7 @@ secp256k1 = { workspace = true, features = [
tokio.workspace = true
reth-network.workspace = true
reth-chainspec.workspace = true
reth-network-api.workspace = true
reth-primitives.workspace = true
serde_json.workspace = true
reth-tracing.workspace = true

View File

@ -15,6 +15,7 @@ use reth_network::{
config::NetworkMode, EthNetworkPrimitives, NetworkConfig, NetworkEvent,
NetworkEventListenerProvider, NetworkManager,
};
use reth_network_api::events::SessionInfo;
use reth_tracing::{
tracing::info, tracing_subscriber::filter::LevelFilter, LayerInfo, LogFormat, RethTracer,
Tracer,
@ -71,7 +72,8 @@ async fn main() {
while let Some(evt) = events.next().await {
// For the sake of the example we only print the session established event
// with the chain specific details
if let NetworkEvent::SessionEstablished { status, client_version, .. } = evt {
if let NetworkEvent::ActivePeerSession { info, .. } = evt {
let SessionInfo { status, client_version, .. } = info;
let chain = status.chain;
info!(?chain, ?client_version, "Session established with a new peer.");
}