Skip to content

Commit a4f58dc

Browse files
open_database avoids creating a wallet dir if...
...not necessary This is useful for the wasm integration, where we want to call the `open_database` function directly, without wanting it to create any directories. Note that when using bdk-cli normally, it won't create a db directory if it's useless, but it will still create a base directory (even if empty). This is suboptimal, but fixing it would require a quite big refactor to the code.
1 parent 7869bdb commit a4f58dc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/utils.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ pub(crate) fn prepare_home_dir(home_path: Option<PathBuf>) -> Result<PathBuf, Er
163163
}
164164

165165
/// prepare bdk_cli wallet directory
166+
#[cfg(any(
167+
feature = "key-value-db",
168+
feature = "sqlite-db",
169+
feature = "compact_filters"
170+
))]
166171
fn prepare_wallet_dir(wallet_name: &str, home_path: &Path) -> Result<PathBuf, Error> {
167172
let mut dir = home_path.to_owned();
168173

@@ -177,6 +182,7 @@ fn prepare_wallet_dir(wallet_name: &str, home_path: &Path) -> Result<PathBuf, Er
177182
}
178183

179184
/// Prepare wallet database directory
185+
#[cfg(any(feature = "key-value-db", feature = "sqlite-db",))]
180186
fn prepare_wallet_db_dir(wallet_name: &str, home_path: &Path) -> Result<PathBuf, Error> {
181187
let mut db_dir = prepare_wallet_dir(wallet_name, home_path)?;
182188

@@ -252,7 +258,9 @@ pub(crate) fn open_database(
252258
wallet_opts: &WalletOpts,
253259
home_path: &Path,
254260
) -> Result<AnyDatabase, Error> {
261+
#![allow(unused_variables)]
255262
let wallet_name = wallet_opts.wallet.as_ref().expect("wallet name");
263+
#[cfg(any(feature = "key-value-db", feature = "sqlite-db",))]
256264
let database_path = prepare_wallet_db_dir(wallet_name, home_path)?;
257265

258266
#[cfg(feature = "key-value-db")]

0 commit comments

Comments
 (0)