mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-05 23:03:07 +00:00
Extract shared recovery path setup for nodes
This commit is contained in:
parent
d2e2743514
commit
f6e6244226
@ -1,4 +1,23 @@
|
||||
#![allow(dead_code)]
|
||||
use std::{fs, io, path::Path};
|
||||
|
||||
/// Shared config path helpers (placeholder).
|
||||
pub struct RecoveryPathsSetup;
|
||||
/// Ensure recovery-related directories and placeholder files exist under the
|
||||
/// given base dir.
|
||||
pub fn ensure_recovery_paths(base_dir: &Path) -> io::Result<()> {
|
||||
let recovery_dir = base_dir.join("recovery");
|
||||
fs::create_dir_all(&recovery_dir)?;
|
||||
|
||||
let mempool_path = recovery_dir.join("mempool.json");
|
||||
if !mempool_path.exists() {
|
||||
fs::write(&mempool_path, "{}")?;
|
||||
}
|
||||
|
||||
let blend_core_path = recovery_dir.join("blend").join("core.json");
|
||||
if let Some(parent) = blend_core_path.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
if !blend_core_path.exists() {
|
||||
fs::write(&blend_core_path, "{}")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ use crate::{
|
||||
LOGS_PREFIX,
|
||||
common::{
|
||||
binary::{BinaryConfig, BinaryResolver},
|
||||
config::injection::inject_ibd_into_cryptarchia,
|
||||
config::{injection::inject_ibd_into_cryptarchia, paths::ensure_recovery_paths},
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -76,19 +76,7 @@ impl Executor {
|
||||
|
||||
// Ensure recovery files/dirs exist so services that persist state do not fail
|
||||
// on startup.
|
||||
let recovery_dir = dir.path().join("recovery");
|
||||
let _ = std::fs::create_dir_all(&recovery_dir);
|
||||
let mempool_path = recovery_dir.join("mempool.json");
|
||||
if !mempool_path.exists() {
|
||||
let _ = std::fs::write(&mempool_path, "{}");
|
||||
}
|
||||
let blend_core_path = recovery_dir.join("blend").join("core.json");
|
||||
if let Some(parent) = blend_core_path.parent() {
|
||||
let _ = std::fs::create_dir_all(parent);
|
||||
}
|
||||
if !blend_core_path.exists() {
|
||||
let _ = std::fs::write(&blend_core_path, "{}");
|
||||
}
|
||||
let _ = ensure_recovery_paths(dir.path());
|
||||
|
||||
if !*IS_DEBUG_TRACING {
|
||||
if let Ok(env_dir) = std::env::var("NOMOS_LOG_DIR") {
|
||||
|
||||
@ -29,7 +29,7 @@ use crate::{
|
||||
LOGS_PREFIX,
|
||||
common::{
|
||||
binary::{BinaryConfig, BinaryResolver},
|
||||
config::injection::inject_ibd_into_cryptarchia,
|
||||
config::{injection::inject_ibd_into_cryptarchia, paths::ensure_recovery_paths},
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -103,19 +103,7 @@ impl Validator {
|
||||
|
||||
// Ensure recovery files/dirs exist so services that persist state do not fail
|
||||
// on startup.
|
||||
let recovery_dir = dir.path().join("recovery");
|
||||
let _ = std::fs::create_dir_all(&recovery_dir);
|
||||
let mempool_path = recovery_dir.join("mempool.json");
|
||||
if !mempool_path.exists() {
|
||||
let _ = std::fs::write(&mempool_path, "{}");
|
||||
}
|
||||
let blend_core_path = recovery_dir.join("blend").join("core.json");
|
||||
if let Some(parent) = blend_core_path.parent() {
|
||||
let _ = std::fs::create_dir_all(parent);
|
||||
}
|
||||
if !blend_core_path.exists() {
|
||||
let _ = std::fs::write(&blend_core_path, "{}");
|
||||
}
|
||||
let _ = ensure_recovery_paths(dir.path());
|
||||
|
||||
if !*IS_DEBUG_TRACING {
|
||||
if let Ok(env_dir) = std::env::var("NOMOS_LOG_DIR") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user