]> Untitled Git - bdk-cli/commitdiff
Create node backend once in repl mode
authorSteve Myers <steve@notmandatory.org>
Sat, 10 Sep 2022 02:50:02 +0000 (21:50 -0500)
committerSteve Myers <steve@notmandatory.org>
Sat, 10 Sep 2022 03:01:41 +0000 (22:01 -0500)
src/handlers.rs

index 30ec993704c92ce2aa46ce7a7d4c847c9e3fbca0..536ce7d639a3c0b8098907f33e073fa40f1851e9 100644 (file)
@@ -592,6 +592,14 @@ pub(crate) fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
             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<String, Error> {
                         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<String, Error> {
                                 subcommand:
                                     WalletSubCommand::OnlineWalletSubCommand(online_subcommand),
                             } => {
-                                let backend = new_backend(&home_dir)?;
                                 let blockchain = new_blockchain(
                                     cli_opts.network,
                                     &wallet_opts,