Skip to content

Commit

Permalink
fix(dht): sets file default for DHT db (#4030)
Browse files Browse the repository at this point in the history
Description
---
- sets database file default for DHT db on the p2p level

Motivation and Context
---
Default was using ephemeral memory db

How Has This Been Tested?
---
Manually, base node does not emit error on linux
  • Loading branch information
sdbondi authored Apr 12, 2022
1 parent c95e589 commit 5b125e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions base_layer/p2p/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use tari_common::{
SubConfigPath,
};
use tari_comms::multiaddr::Multiaddr;
use tari_comms_dht::DhtConfig;
use tari_comms_dht::{DbConnectionUrl, DhtConfig};

use crate::{transport::TransportConfig, DEFAULT_DNS_NAME_SERVER};

Expand Down Expand Up @@ -131,7 +131,10 @@ impl Default for P2pConfig {
max_concurrent_inbound_tasks: 50,
max_concurrent_outbound_tasks: 100,
outbound_buffer_size: 100,
dht: Default::default(),
dht: DhtConfig {
database_url: DbConnectionUrl::file("dht.sqlite"),
..Default::default()
},
allow_test_addresses: false,
listener_liveness_max_sessions: 0,
listener_liveness_allowlist_cidrs: StringList::default(),
Expand Down
4 changes: 4 additions & 0 deletions comms/dht/src/storage/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub enum DbConnectionUrl {
}

impl DbConnectionUrl {
pub fn file<P: AsRef<Path>>(path: P) -> Self {
DbConnectionUrl::File(path.as_ref().to_path_buf())
}

pub fn to_url_string(&self) -> String {
use DbConnectionUrl::{File, Memory, MemoryShared};
match self {
Expand Down

0 comments on commit 5b125e7

Please sign in to comment.