Skip to content

Commit 8b31e5f

Browse files
committed
Merge #94: Add Batch::raw and improve docs
adb0c74 Add `Batch::raw` and improve docs (志宇) Pull request description: Being able to add raw requests to `Batch` makes sense from an API standpoint because we already allow raw non-batched requests. This is also useful when the electrum server API gets an updated version and our client is unable to keep up. Additional to this, I have improved the documentation and made `Call` private (since `Call` is never used externally). ACKs for top commit: notmandatory: ACK adb0c74 Tree-SHA512: 808dccf1152b750881e45a9709fb4127835ecff3da5ecccffcb9f03e62171192c58154860195db7d3d3467ae8e3e450bba845ff4e8d4dffb302c3d8d6eb837fd
2 parents 5ecb26f + adb0c74 commit 8b31e5f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/batch.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ pub struct Batch {
2121
}
2222

2323
impl Batch {
24+
/// Add a raw request to the batch queue
25+
pub fn raw(&mut self, method: String, params: Vec<Param>) {
26+
self.calls.push((method, params));
27+
}
28+
2429
/// Add one `blockchain.scripthash.listunspent` request to the batch queue
2530
pub fn script_list_unspent(&mut self, script: &Script) {
2631
let params = vec![Param::String(script.to_electrum_scripthash().to_hex())];

src/config.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
use std::time::Duration;
22

3+
/// Configuration for an electrum client
4+
///
5+
/// Refer to [`Client::from_config`] and [`ClientType::from_config`].
6+
///
7+
/// [`Client::from_config`]: crate::Client::from_config
8+
/// [`ClientType::from_config`]: crate::ClientType::from_config
39
#[derive(Debug, Clone)]
410
pub struct Config {
511
/// Proxy socks5 configuration, default None
@@ -97,19 +103,35 @@ impl Socks5Config {
97103
}
98104

99105
impl Config {
106+
/// Get the configuration for `socks5`
107+
///
108+
/// Set this with [`ConfigBuilder::socks5`]
100109
pub fn socks5(&self) -> &Option<Socks5Config> {
101110
&self.socks5
102111
}
112+
113+
/// Get the configuration for `retry`
114+
///
115+
/// Set this with [`ConfigBuilder::retry`]
103116
pub fn retry(&self) -> u8 {
104117
self.retry
105118
}
119+
120+
/// Get the configuration for `timeout`
121+
///
122+
/// Set this with [`ConfigBuilder::timeout`]
106123
pub fn timeout(&self) -> Option<Duration> {
107124
self.timeout
108125
}
126+
127+
/// Get the configuration for `validate_domain`
128+
///
129+
/// Set this with [`ConfigBuilder::validate_domain`]
109130
pub fn validate_domain(&self) -> bool {
110131
self.validate_domain
111132
}
112133

134+
/// Convenience method for calling [`ConfigBuilder::new`]
113135
pub fn builder() -> ConfigBuilder {
114136
ConfigBuilder::new()
115137
}

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use serde::{de, Deserialize, Serialize};
1818

1919
static JSONRPC_2_0: &str = "2.0";
2020

21-
pub type Call = (String, Vec<Param>);
21+
pub(crate) type Call = (String, Vec<Param>);
2222

2323
#[derive(Serialize, Clone)]
2424
#[serde(untagged)]

0 commit comments

Comments
 (0)