Skip to content

Commit

Permalink
add backend-type in conf
Browse files Browse the repository at this point in the history
  • Loading branch information
pythcoiner committed Sep 25, 2024
1 parent d0e740d commit 245b565
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub use electrum_client;
pub use error::Error;
pub use which;

pub enum Backend {
Electrs,
Esplora,
Mempool,
}

/// Electrs configuration parameters, implements a convenient [Default] for most common use.
///
/// Default values:
Expand Down Expand Up @@ -81,6 +87,9 @@ pub struct Conf<'a> {
/// Persistent directory path
pub staticdir: Option<PathBuf>,

/// The backend type in use
pub backend: Backend,

/// Try to spawn the process `attempt` time
///
/// The OS is giving available ports to use, however, they aren't booked, so it could rarely
Expand Down Expand Up @@ -110,6 +119,7 @@ impl Default for Conf<'_> {
staticdir: None,
attempts: 3,
buffered_logs: false,
backend: Backend::Electrs,
}
}
}
Expand Down Expand Up @@ -202,7 +212,11 @@ impl ElectrsD {
let cookie_file;
#[cfg(not(feature = "legacy"))]
{
args.push("--cookie-file");
if let Backend::Esplora = conf.backend {
args.push("--cookie");
} else {
args.push("--cookie-file");
}
cookie_file = format!("{}", bitcoind.params.cookie_file.display());
args.push(&cookie_file);
}
Expand Down

0 comments on commit 245b565

Please sign in to comment.