refactor: replace std::fs usages with reth-primitives (#5813)

This commit is contained in:
Alexey Shekhirin
2023-12-18 17:56:26 +02:00
committed by GitHub
parent 18dd1b72a1
commit 0e091dafb8
5 changed files with 13 additions and 11 deletions

View File

@ -179,7 +179,7 @@ impl Command {
let mut blobs_bundle = self
.blobs_bundle_path
.map(|path| -> eyre::Result<BlobsBundleV1> {
let contents = std::fs::read_to_string(&path)
let contents = fs::read_to_string(&path)
.wrap_err(format!("could not read {}", path.display()))?;
serde_json::from_str(&contents).wrap_err("failed to deserialize blobs bundle")
})

View File

@ -56,6 +56,7 @@ use reth_network::{NetworkBuilder, NetworkConfig, NetworkEvents, NetworkHandle,
use reth_network_api::{NetworkInfo, PeersInfo};
use reth_primitives::{
constants::eip4844::{LoadKzgSettingsError, MAINNET_KZG_TRUSTED_SETUP},
fs,
kzg::KzgSettings,
stage::StageId,
BlockHashOrNumber, BlockNumber, ChainSpec, DisplayHardforks, Head, SealedHeader, B256,
@ -1056,8 +1057,8 @@ async fn run_network_until_shutdown<C>(
let known_peers = network.all_peers().collect::<Vec<_>>();
if let Ok(known_peers) = serde_json::to_string_pretty(&known_peers) {
trace!(target: "reth::cli", peers_file =?file_path, num_peers=%known_peers.len(), "Saving current peers");
let parent_dir = file_path.parent().map(std::fs::create_dir_all).transpose();
match parent_dir.and_then(|_| std::fs::write(&file_path, known_peers)) {
let parent_dir = file_path.parent().map(fs::create_dir_all).transpose();
match parent_dir.and_then(|_| fs::write(&file_path, known_peers)) {
Ok(_) => {
info!(target: "reth::cli", peers_file=?file_path, "Wrote network peers to file");
}