Skip to content

Commit

Permalink
fix: move peer dbs into sub folders (#4147)
Browse files Browse the repository at this point in the history
Description
---
Add sub folders for each application's peer DB

Motivation and Context
---
If you run the base node and validator node in the same folder, you will get a file lock error. I added the same folder to the console wallet to keep it the same

How Has This Been Tested?
---
cargo test
  • Loading branch information
stringhandler authored May 30, 2022
1 parent f79d383 commit 2b1a69a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
6 changes: 5 additions & 1 deletion applications/tari_base_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,18 @@ pub struct BaseNodeConfig {

impl Default for BaseNodeConfig {
fn default() -> Self {
let p2p = P2pConfig {
datastore_path: PathBuf::from("peer_db/base_node"),
..Default::default()
};
Self {
override_from: None,
network: Network::LocalNet,
grpc_address: Some("/ip4/127.0.0.1/tcp/18142".parse().unwrap()),
identity_file: PathBuf::from("config/base_node_id.json"),
use_libtor: false,
tor_identity_file: PathBuf::from("config/tor_id.json"),
p2p: P2pConfig::default(),
p2p,
db_type: DatabaseType::Lmdb,
lmdb: Default::default(),
data_dir: PathBuf::from("data/base_node"),
Expand Down
8 changes: 4 additions & 4 deletions applications/tari_validator_node/src/comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ pub async fn build_service_and_comms_stack(
) -> Result<(ServiceHandles, SubscriptionFactory), ExitError> {
let (publisher, peer_message_subscriptions) = pubsub_connector(100, 50);

let mut transport_config = config.validator_node.p2p.transport.clone();
transport_config.tor.identity = load_from_json(&config.validator_node.tor_identity_file)
let mut p2p_config = config.validator_node.p2p.clone();
p2p_config.transport.tor.identity = load_from_json(&config.validator_node.tor_identity_file)
.map_err(|e| ExitError::new(ExitCode::ConfigError, e))?;

let mut handles = StackBuilder::new(shutdown.clone())
.add_initializer(P2pInitializer::new(
config.validator_node.p2p.clone(),
p2p_config.clone(),
config.peer_seeds.clone(),
// TODO: configurable
Network::Dibbler,
Expand All @@ -73,7 +73,7 @@ pub async fn build_service_and_comms_stack(

let comms = setup_p2p_rpc(config, comms, &handles, mempool, db_factory, asset_processor);

let comms = spawn_comms_using_transport(comms, transport_config)
let comms = spawn_comms_using_transport(comms, p2p_config.transport.clone())
.await
.map_err(|e| ExitError::new(ExitCode::ConfigError, format!("Could not spawn using transport: {}", e)))?;

Expand Down
7 changes: 6 additions & 1 deletion applications/tari_validator_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ impl ValidatorNodeConfig {

impl Default for ValidatorNodeConfig {
fn default() -> Self {
let p2p = P2pConfig {
datastore_path: PathBuf::from("peer_db/validator_node"),
..Default::default()
};

Self {
override_from: None,
identity_file: PathBuf::from("validator_node_id.json"),
Expand All @@ -98,7 +103,7 @@ impl Default for ValidatorNodeConfig {
data_dir: PathBuf::from("/data/validator_node"),
committee_management_confirmation_time: 10,
committee_management_polling_interval: 5,
p2p: P2pConfig::default(),
p2p,
grpc_address: Some("/ip4/127.0.0.1/tcp/18144".parse().unwrap()),
}
}
Expand Down
6 changes: 5 additions & 1 deletion base_layer/wallet/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ pub struct WalletConfig {

impl Default for WalletConfig {
fn default() -> Self {
let p2p = P2pConfig {
datastore_path: PathBuf::from("peer_db/wallet"),
..Default::default()
};
Self {
override_from: None,
p2p: Default::default(),
p2p,
transaction_service_config: Default::default(),
output_manager_service_config: Default::default(),
buffer_size: 100,
Expand Down

0 comments on commit 2b1a69a

Please sign in to comment.