Skip to content

Commit fa0454e

Browse files
committed
Create node backend once in repl mode
1 parent 322f6f1 commit fa0454e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/handlers.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,14 @@ pub(crate) fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
592592
let split_regex = Regex::new(crate::REPL_LINE_SPLIT_REGEX)
593593
.map_err(|e| Error::Generic(e.to_string()))?;
594594

595+
#[cfg(any(
596+
feature = "electrum",
597+
feature = "esplora",
598+
feature = "compact_filters",
599+
feature = "rpc"
600+
))]
601+
let backend = new_backend(&home_dir)?;
602+
595603
loop {
596604
let readline = rl.readline(">> ");
597605
match readline {
@@ -622,7 +630,6 @@ pub(crate) fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
622630
let result = match repl_subcommand {
623631
#[cfg(feature = "regtest-node")]
624632
ReplSubCommand::Node { subcommand } => {
625-
let backend = new_backend(&home_dir)?;
626633
match backend.exec_cmd(subcommand) {
627634
Ok(result) => Ok(result),
628635
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> {
638645
subcommand:
639646
WalletSubCommand::OnlineWalletSubCommand(online_subcommand),
640647
} => {
641-
let backend = new_backend(&home_dir)?;
642648
let blockchain = new_blockchain(
643649
cli_opts.network,
644650
&wallet_opts,

0 commit comments

Comments
 (0)