From d7f02b8c7dc7389e7ceb5e5480bce68074466df4 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Tue, 17 Nov 2020 09:58:29 +0100 Subject: [PATCH] Allow to set concurrency in Esplora config and optionally pass it in repl --- examples/repl.rs | 3 +++ src/cli.rs | 25 +++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/repl.rs b/examples/repl.rs index 69eca92..09e75f9 100644 --- a/examples/repl.rs +++ b/examples/repl.rs @@ -95,6 +95,9 @@ fn main() { let config = match matches.value_of("esplora") { Some(base_url) => AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { base_url: base_url.to_string(), + concurrency: matches + .value_of("esplora_concurrency") + .and_then(|v| v.parse::().ok()), }), None => AnyBlockchainConfig::Electrum(ElectrumBlockchainConfig { url: matches.value_of("server").unwrap().to_string(), diff --git a/src/cli.rs b/src/cli.rs index 06c11d4..350614e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -362,14 +362,23 @@ pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { ); if cfg!(feature = "esplora") { - app = app.arg( - Arg::with_name("esplora") - .short("e") - .long("esplora") - .value_name("ESPLORA") - .help("Use the esplora server if given as parameter") - .takes_value(true), - ); + app = app + .arg( + Arg::with_name("esplora") + .short("e") + .long("esplora") + .value_name("ESPLORA") + .help("Use the esplora server if given as parameter") + .takes_value(true), + ) + .arg( + Arg::with_name("esplora_concurrency") + .long("esplora_concurrency") + .value_name("ESPLORA_CONCURRENCY") + .help("Concurrency of requests made to the esplora server") + .default_value("4") + .takes_value(true), + ) } if cfg!(feature = "electrum") { -- 2.49.0