mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-04 06:13:09 +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).
|
/// Ensure recovery-related directories and placeholder files exist under the
|
||||||
pub struct RecoveryPathsSetup;
|
/// 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,
|
LOGS_PREFIX,
|
||||||
common::{
|
common::{
|
||||||
binary::{BinaryConfig, BinaryResolver},
|
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
|
// Ensure recovery files/dirs exist so services that persist state do not fail
|
||||||
// on startup.
|
// on startup.
|
||||||
let recovery_dir = dir.path().join("recovery");
|
let _ = ensure_recovery_paths(dir.path());
|
||||||
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, "{}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if !*IS_DEBUG_TRACING {
|
if !*IS_DEBUG_TRACING {
|
||||||
if let Ok(env_dir) = std::env::var("NOMOS_LOG_DIR") {
|
if let Ok(env_dir) = std::env::var("NOMOS_LOG_DIR") {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ use crate::{
|
|||||||
LOGS_PREFIX,
|
LOGS_PREFIX,
|
||||||
common::{
|
common::{
|
||||||
binary::{BinaryConfig, BinaryResolver},
|
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
|
// Ensure recovery files/dirs exist so services that persist state do not fail
|
||||||
// on startup.
|
// on startup.
|
||||||
let recovery_dir = dir.path().join("recovery");
|
let _ = ensure_recovery_paths(dir.path());
|
||||||
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, "{}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if !*IS_DEBUG_TRACING {
|
if !*IS_DEBUG_TRACING {
|
||||||
if let Ok(env_dir) = std::env::var("NOMOS_LOG_DIR") {
|
if let Ok(env_dir) = std::env::var("NOMOS_LOG_DIR") {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user