mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
refactor: move write_peers_to_file to NetworkManager impl (#9134)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -72,5 +72,8 @@ confy.workspace = true
|
||||
rayon.workspace = true
|
||||
backon.workspace = true
|
||||
|
||||
# tracing
|
||||
tracing.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile.workspace = true
|
||||
|
||||
@@ -30,7 +30,6 @@ use reth_node_core::{
|
||||
dirs::{ChainPath, DataDirPath, MaybePlatformPath},
|
||||
node_config::NodeConfig,
|
||||
primitives::Head,
|
||||
utils::write_peers_to_file,
|
||||
};
|
||||
use reth_primitives::revm_primitives::EnvKzgSettings;
|
||||
use reth_provider::{providers::BlockchainProvider, ChainSpecProvider};
|
||||
@@ -39,6 +38,7 @@ use reth_transaction_pool::{PoolConfig, TransactionPool};
|
||||
use secp256k1::SecretKey;
|
||||
pub use states::*;
|
||||
use std::sync::Arc;
|
||||
use tracing::{info, trace, warn};
|
||||
|
||||
mod states;
|
||||
|
||||
@@ -509,7 +509,18 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
|
||||
"p2p network task",
|
||||
|shutdown| {
|
||||
network.run_until_graceful_shutdown(shutdown, |network| {
|
||||
write_peers_to_file(&network, known_peers_file)
|
||||
if let Some(peers_file) = known_peers_file {
|
||||
let num_known_peers = network.num_known_peers();
|
||||
trace!(target: "reth::cli", peers_file=?peers_file, num_peers=%num_known_peers, "Saving current peers");
|
||||
match network.write_peers_to_file(peers_file.as_path()) {
|
||||
Ok(_) => {
|
||||
info!(target: "reth::cli", peers_file=?peers_file, "Wrote network peers to file");
|
||||
}
|
||||
Err(err) => {
|
||||
warn!(target: "reth::cli", %err, "Failed to write network peers to file");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user