Skip to content

Commit adb0c74

Browse files
committed
Add Batch::raw and improve docs
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).
1 parent 1290819 commit adb0c74

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/batch.rs

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

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

src/config.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
use crate::Error;
21
use std::time::Duration;
32

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
49
#[derive(Debug, Clone)]
510
pub struct Config {
611
/// Proxy socks5 configuration, default None
@@ -98,19 +103,35 @@ impl Socks5Config {
98103
}
99104

100105
impl Config {
106+
/// Get the configuration for `socks5`
107+
///
108+
/// Set this with [`ConfigBuilder::socks5`]
101109
pub fn socks5(&self) -> &Option<Socks5Config> {
102110
&self.socks5
103111
}
112+
113+
/// Get the configuration for `retry`
114+
///
115+
/// Set this with [`ConfigBuilder::retry`]
104116
pub fn retry(&self) -> u8 {
105117
self.retry
106118
}
119+
120+
/// Get the configuration for `timeout`
121+
///
122+
/// Set this with [`ConfigBuilder::timeout`]
107123
pub fn timeout(&self) -> Option<Duration> {
108124
self.timeout
109125
}
126+
127+
/// Get the configuration for `validate_domain`
128+
///
129+
/// Set this with [`ConfigBuilder::validate_domain`]
110130
pub fn validate_domain(&self) -> bool {
111131
self.validate_domain
112132
}
113133

134+
/// Convenience method for calling [`ConfigBuilder::new`]
114135
pub fn builder() -> ConfigBuilder {
115136
ConfigBuilder::new()
116137
}

src/types.rs

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

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

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

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

0 commit comments

Comments
 (0)