Skip to content

Commit 390fe6d

Browse files
Implement Deref<Target=UrlClient> for EsploraBlockchain
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.
1 parent 9f9ffd0 commit 390fe6d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/blockchain/esplora/reqwest.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ struct UrlClient {
4646
/// See the [`blockchain::esplora`](crate::blockchain::esplora) module for a usage example.
4747
#[derive(Debug)]
4848
pub struct EsploraBlockchain {
49-
url_client: UrlClient,
49+
/// Esplora reqwest client
50+
pub url_client: UrlClient,
5051
stop_gap: usize,
5152
}
5253

@@ -101,6 +102,14 @@ impl Blockchain for EsploraBlockchain {
101102
}
102103
}
103104

105+
impl Deref for EsploraBlockchain {
106+
type Target = UrlClient;
107+
108+
fn deref(&self) -> &Self::Target {
109+
&self.url_client
110+
}
111+
}
112+
104113
impl StatelessBlockchain for EsploraBlockchain {}
105114

106115
#[maybe_async]

src/blockchain/esplora/ureq.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ struct UrlClient {
4545
/// See the [`blockchain::esplora`](crate::blockchain::esplora) module for a usage example.
4646
#[derive(Debug)]
4747
pub struct EsploraBlockchain {
48-
url_client: UrlClient,
48+
/// Esplora ureq client
49+
pub url_client: UrlClient,
4950
stop_gap: usize,
5051
concurrency: u8,
5152
}
@@ -98,6 +99,14 @@ impl Blockchain for EsploraBlockchain {
9899
}
99100
}
100101

102+
impl Deref for EsploraBlockchain {
103+
type Target = UrlClient;
104+
105+
fn deref(&self) -> &Self::Target {
106+
&self.url_client
107+
}
108+
}
109+
101110
impl StatelessBlockchain for EsploraBlockchain {}
102111

103112
impl GetHeight for EsploraBlockchain {

0 commit comments

Comments
 (0)