Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/blockchain/esplora/reqwest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! Esplora by way of `reqwest` HTTP client.

use std::collections::{HashMap, HashSet};
use std::ops::Deref;

use bitcoin::consensus::{deserialize, serialize};
use bitcoin::hashes::hex::{FromHex, ToHex};
Expand All @@ -31,8 +32,9 @@ use crate::database::BatchDatabase;
use crate::error::Error;
use crate::FeeRate;

/// Structure encapsulates Esplora client
#[derive(Debug)]
struct UrlClient {
pub struct UrlClient {
url: String,
// We use the async client instead of the blocking one because it automatically uses `fetch`
// when the target platform is wasm32.
Expand Down Expand Up @@ -101,6 +103,14 @@ impl Blockchain for EsploraBlockchain {
}
}

impl Deref for EsploraBlockchain {
type Target = UrlClient;

fn deref(&self) -> &Self::Target {
&self.url_client
}
}

impl StatelessBlockchain for EsploraBlockchain {}

#[maybe_async]
Expand Down
12 changes: 11 additions & 1 deletion src/blockchain/esplora/ureq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use std::collections::{HashMap, HashSet};
use std::io;
use std::io::Read;
use std::ops::Deref;
use std::time::Duration;

#[allow(unused_imports)]
Expand All @@ -33,8 +34,9 @@ use crate::database::BatchDatabase;
use crate::error::Error;
use crate::FeeRate;

/// Structure encapsulates ureq Esplora client
#[derive(Debug, Clone)]
struct UrlClient {
pub struct UrlClient {
url: String,
agent: Agent,
}
Expand Down Expand Up @@ -98,6 +100,14 @@ impl Blockchain for EsploraBlockchain {
}
}

impl Deref for EsploraBlockchain {
type Target = UrlClient;

fn deref(&self) -> &Self::Target {
&self.url_client
}
}

impl StatelessBlockchain for EsploraBlockchain {}

impl GetHeight for EsploraBlockchain {
Expand Down