Skip to content

Commit

Permalink
Implement Deref<Target=UrlClient> for EsploraBlockchain
Browse files Browse the repository at this point in the history
There is currently no way to access the client
from the EsploraBlockchain. This makes it difficult
for users to extend it's functionality. This PR exposes
both the reqwest and ureq clients. This PR is related to
PR bitcoindevkit#705.
  • Loading branch information
vladimirfomene committed Aug 15, 2022
1 parent 9f9ffd0 commit 390fe6d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/blockchain/esplora/reqwest.rs
Expand Up @@ -46,7 +46,8 @@ struct UrlClient {
/// See the [`blockchain::esplora`](crate::blockchain::esplora) module for a usage example.
#[derive(Debug)]
pub struct EsploraBlockchain {
url_client: UrlClient,
/// Esplora reqwest client
pub url_client: UrlClient,
stop_gap: usize,
}

Expand Down Expand Up @@ -101,6 +102,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
11 changes: 10 additions & 1 deletion src/blockchain/esplora/ureq.rs
Expand Up @@ -45,7 +45,8 @@ struct UrlClient {
/// See the [`blockchain::esplora`](crate::blockchain::esplora) module for a usage example.
#[derive(Debug)]
pub struct EsploraBlockchain {
url_client: UrlClient,
/// Esplora ureq client
pub url_client: UrlClient,
stop_gap: usize,
concurrency: u8,
}
Expand Down Expand Up @@ -98,6 +99,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

0 comments on commit 390fe6d

Please sign in to comment.