From: Steve Myers Date: Sat, 10 Sep 2022 02:50:02 +0000 (-0500) Subject: Create node backend once in repl mode X-Git-Tag: v0.6.0~5^2 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.OddLengthStringError.html?a=commitdiff_plain;h=fa0454e9728ceea5bdbffb9ed0e51a32db7c74ab;p=bdk-cli Create node backend once in repl mode --- diff --git a/src/handlers.rs b/src/handlers.rs index 30ec993..536ce7d 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -592,6 +592,14 @@ pub(crate) fn handle_command(cli_opts: CliOpts) -> Result { let split_regex = Regex::new(crate::REPL_LINE_SPLIT_REGEX) .map_err(|e| Error::Generic(e.to_string()))?; + #[cfg(any( + feature = "electrum", + feature = "esplora", + feature = "compact_filters", + feature = "rpc" + ))] + let backend = new_backend(&home_dir)?; + loop { let readline = rl.readline(">> "); match readline { @@ -622,7 +630,6 @@ pub(crate) fn handle_command(cli_opts: CliOpts) -> Result { let result = match repl_subcommand { #[cfg(feature = "regtest-node")] ReplSubCommand::Node { subcommand } => { - let backend = new_backend(&home_dir)?; match backend.exec_cmd(subcommand) { Ok(result) => Ok(result), Err(e) => Ok(serde_json::Value::String(e.to_string())), @@ -638,7 +645,6 @@ pub(crate) fn handle_command(cli_opts: CliOpts) -> Result { subcommand: WalletSubCommand::OnlineWalletSubCommand(online_subcommand), } => { - let backend = new_backend(&home_dir)?; let blockchain = new_blockchain( cli_opts.network, &wallet_opts,