Skip to content

Commit

Permalink
Merge pull request maidsafe#2243 from maqi/record_store_dir_prefixed_…
Browse files Browse the repository at this point in the history
…with_network_keys

feat(node): using different storage dir for different network
  • Loading branch information
maqi authored Oct 15, 2024
2 parents 00ad51d + 069060b commit 147ba8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions sn_networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ use sn_protocol::{
messages::{ChunkProof, Nonce, Request, Response},
storage::{try_deserialize_record, RetryStrategy},
version::{
IDENTIFY_CLIENT_VERSION_STR, IDENTIFY_NODE_VERSION_STR, IDENTIFY_PROTOCOL_STR,
REQ_RESPONSE_VERSION_STR,
get_key_version_str, IDENTIFY_CLIENT_VERSION_STR, IDENTIFY_NODE_VERSION_STR,
IDENTIFY_PROTOCOL_STR, REQ_RESPONSE_VERSION_STR,
},
NetworkAddress, PrettyPrintKBucketKey, PrettyPrintRecordKey,
};
Expand Down Expand Up @@ -364,7 +364,8 @@ impl NetworkBuilder {

let store_cfg = {
// Configures the disk_store to store records under the provided path and increase the max record size
let storage_dir_path = root_dir.join("record_store");
// The storage dir is appendixed with key_version str to avoid bringing records from old network into new
let storage_dir_path = root_dir.join(format!("record_store_{}", get_key_version_str()));
if let Err(error) = std::fs::create_dir_all(&storage_dir_path) {
return Err(NetworkError::FailedToCreateRecordStoreDir {
path: storage_dir_path,
Expand Down
2 changes: 1 addition & 1 deletion sn_protocol/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn get_truncate_version_str() -> String {
/// Get the PKs version string.
/// If the public key mis-configed via env variable,
/// it shall result in being rejected to join by the network
fn get_key_version_str() -> String {
pub fn get_key_version_str() -> String {
let mut f_k_str = FOUNDATION_PK.to_hex();
let _ = f_k_str.split_off(6);
let mut g_k_str = GENESIS_PK.to_hex();
Expand Down

0 comments on commit 147ba8e

Please sign in to comment.