Skip to content

Commit

Permalink
Merge pull request #2299 from subspace/move-node-known_addresses
Browse files Browse the repository at this point in the history
Move `known_addresses.bin` of the node into `network` directory
  • Loading branch information
nazar-pc authored Dec 7, 2023
2 parents 849393c + 8bf8dce commit a84fda7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/subspace-service/src/dsn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,25 @@ pub(crate) fn create_dsn_instance(
let metrics = enable_metrics.then(|| Metrics::new(&mut metric_registry));

let networking_parameters_registry = {
// TODO: Make `base_path` point to `network` once we can clean up below migration code
let path = dsn_config.base_path;
let network_path = path.join("network");

// TODO: Remove this in the future after enough upgrade time that this no longer exist
if path.join("known_addresses_db").is_dir() {
let _ = fs::remove_file(path.join("known_addresses_db"));
}
let file_path = path.join("known_addresses.bin");
if !network_path.is_dir() {
fs::create_dir(&network_path)
.map_err(|error| DsnConfigurationError::CreationError(CreationError::Io(error)))?;
}
if path.join("known_addresses.bin").is_dir() {
let _ = fs::rename(
path.join("known_addresses.bin"),
network_path.join("known_addresses.bin"),
);
}
let file_path = network_path.join("known_addresses.bin");

KnownPeersManager::new(KnownPeersManagerConfig {
path: Some(file_path.into_boxed_path()),
Expand Down

0 comments on commit a84fda7

Please sign in to comment.