From 5b125e702b9f6da79b0a4f8922dc002078470e46 Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Tue, 12 Apr 2022 23:14:34 +0400 Subject: [PATCH] fix(dht): sets file default for DHT db (#4030) 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 --- base_layer/p2p/src/config.rs | 7 +++++-- comms/dht/src/storage/connection.rs | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/base_layer/p2p/src/config.rs b/base_layer/p2p/src/config.rs index c38bcfe18f..4f69ddabfc 100644 --- a/base_layer/p2p/src/config.rs +++ b/base_layer/p2p/src/config.rs @@ -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}; @@ -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(), diff --git a/comms/dht/src/storage/connection.rs b/comms/dht/src/storage/connection.rs index 2199372535..1e8e38f53e 100644 --- a/comms/dht/src/storage/connection.rs +++ b/comms/dht/src/storage/connection.rs @@ -52,6 +52,10 @@ pub enum DbConnectionUrl { } impl DbConnectionUrl { + pub fn file>(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 {