Skip to content

Commit f46018b

Browse files
committed
add backend-type in conf
1 parent d0e740d commit f46018b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/lib.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ pub use electrum_client;
3434
pub use error::Error;
3535
pub use which;
3636

37+
#[derive(Debug, Clone, Eq, PartialEq)]
38+
pub enum Backend {
39+
Electrs,
40+
Esplora,
41+
Mempool,
42+
}
43+
3744
/// Electrs configuration parameters, implements a convenient [Default] for most common use.
3845
///
3946
/// Default values:
@@ -81,6 +88,9 @@ pub struct Conf<'a> {
8188
/// Persistent directory path
8289
pub staticdir: Option<PathBuf>,
8390

91+
/// The backend type in use
92+
pub backend: Backend,
93+
8494
/// Try to spawn the process `attempt` time
8595
///
8696
/// The OS is giving available ports to use, however, they aren't booked, so it could rarely
@@ -110,6 +120,7 @@ impl Default for Conf<'_> {
110120
staticdir: None,
111121
attempts: 3,
112122
buffered_logs: false,
123+
backend: Backend::Electrs,
113124
}
114125
}
115126
}
@@ -202,7 +213,11 @@ impl ElectrsD {
202213
let cookie_file;
203214
#[cfg(not(feature = "legacy"))]
204215
{
205-
args.push("--cookie-file");
216+
if let Backend::Mempool = conf.backend {
217+
args.push("--cookie");
218+
} else {
219+
args.push("--cookie-file");
220+
}
206221
cookie_file = format!("{}", bitcoind.params.cookie_file.display());
207222
args.push(&cookie_file);
208223
}

0 commit comments

Comments
 (0)