Skip to content

Commit

Permalink
fix: compilation error from cli and fmt all
Browse files Browse the repository at this point in the history
  • Loading branch information
will-bitlight committed Jul 15, 2024
1 parent 45833ef commit 07bf47f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ shellexpand = { version = "3.1.0", optional = true }
[features]
default = []
all = ["electrum", "mempool", "fs", "cli", "clap", "log"]
cli = ["base64", "env_logger", "clap", "shellexpand", "fs", "serde", "electrum", "esplora", "log"]
cli = ["base64", "env_logger", "clap", "shellexpand", "fs", "serde", "electrum", "mempool", "log"]
log = ["env_logger"]
electrum = ["bp-electrum", "serde", "serde_json"]
esplora = ["bp-esplora"]
Expand Down
35 changes: 20 additions & 15 deletions src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use strict_encoding::Ident;
use crate::cli::{
Config, DescrStdOpts, DescriptorOpts, ExecError, GeneralOpts, ResolverOpt, WalletOpts,
};
use crate::{AnyIndexer, MayError, Wallet};
use crate::indexers::Client as IndexerClient;
use crate::{AnyIndexer, MayError, Wallet};

/// Command-line arguments
#[derive(Parser)]
Expand Down Expand Up @@ -136,20 +136,25 @@ impl<C: Clone + Eq + Debug + Subcommand, O: DescriptorOpts> Args<C, O> {
};

if sync {
let indexer = match (&self.resolver.esplora, &self.resolver.electrum, &self.resolver.mempool) {
(None, Some(url), None) => AnyIndexer::Electrum(Box::new(electrum::Client::new(url)?)),
(Some(url), None, None) => {
AnyIndexer::Esplora(Box::new(IndexerClient::new_esplora(url)?))
}
(None, None, Some(url)) => AnyIndexer::Mempool(Box::new(IndexerClient::new_mempool(url)?)),
_ => {
eprintln!(
" - error: no blockchain indexer specified; use either --esplora or \
--electrum argument"
);
exit(1);
}
};
let indexer =
match (&self.resolver.esplora, &self.resolver.electrum, &self.resolver.mempool) {
(None, Some(url), None) => {
AnyIndexer::Electrum(Box::new(electrum::Client::new(url)?))

Check warning on line 142 in src/cli/args.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/args.rs#L139-L142

Added lines #L139 - L142 were not covered by tests
}
(Some(url), None, None) => {
AnyIndexer::Esplora(Box::new(IndexerClient::new_esplora(url)?))

Check warning on line 145 in src/cli/args.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/args.rs#L144-L145

Added lines #L144 - L145 were not covered by tests
}
(None, None, Some(url)) => {
AnyIndexer::Mempool(Box::new(IndexerClient::new_mempool(url)?))

Check warning on line 148 in src/cli/args.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/args.rs#L147-L148

Added lines #L147 - L148 were not covered by tests
}
_ => {
eprintln!(
" - error: no blockchain indexer specified; use either --esplora \
--mempool or --electrum argument"
);
exit(1);

Check warning on line 155 in src/cli/args.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/args.rs#L151-L155

Added lines #L151 - L155 were not covered by tests
}
};
eprint!("Syncing");
if let MayError {
err: Some(errors), ..
Expand Down
4 changes: 1 addition & 3 deletions src/indexers/esplora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ impl From<esplora::TxStatus> for TxStatus {
}

impl From<esplora::PrevOut> for Party {
fn from(prevout: esplora::PrevOut) -> Self {
Party::Unknown(prevout.scriptpubkey)
}
fn from(prevout: esplora::PrevOut) -> Self { Party::Unknown(prevout.scriptpubkey) }
}

impl From<esplora::Vin> for TxCredit {
Expand Down
10 changes: 6 additions & 4 deletions src/indexers/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ impl super::Client {
///
/// # Returns
///
/// A `Result` containing the new mempool client if successful, or an `esplora::Error` if an error occurred.
/// A `Result` containing the new mempool client if successful, or an `esplora::Error` if an
/// error occurred.
pub fn new_mempool(url: &str) -> Result<Self, esplora::Error> {
let inner = esplora::Builder::new(url).build_blocking()?;
let client = Self {
Expand All @@ -58,12 +59,13 @@ impl Mempool for BlockingClient {
///
/// * `address` - The address for which to retrieve transactions.
/// * `last_seen` - An optional parameter indicating the last seen transaction ID. If provided,
/// only transactions after the specified ID will be returned.
/// only transactions after the specified ID will be returned.
///
/// # Returns
///
/// Returns a `Result` containing a vector of `esplora::Tx` objects representing the transactions
/// associated with the address, or an `esplora::Error` if an error occurs during the retrieval process.
/// Returns a `Result` containing a vector of `esplora::Tx` objects representing the
/// transactions associated with the address, or an `esplora::Error` if an error occurs
/// during the retrieval process.
fn address_txs(
&self,
address: &String,
Expand Down

0 comments on commit 07bf47f

Please sign in to comment.