Merge bitcoindevkit/rust-electrum-client#88: timeout() and socks() don't return Result
561db261d3`timeout()` and `socks()` don't return Result (Riccardo Casatta) Pull request description: The `Result` was necessary in the past because they couldn't both be set, this is not true anymore after7493630ed8ACKs for top commit: afilini: ACK561db261d3Tree-SHA512: 7654cfbbc7beac6acec786060e373bbc046e1dae0faf2b2ca1df33121e9e92a8f4950c7f8775e44226a62483aeae41c76162cf037ce38137c44d2fedd38560c8
This commit is contained in:
commit
129081999c
@ -6,7 +6,7 @@ fn main() {
|
||||
// NOTE: This assumes Tor is running localy, with an unauthenticated Socks5 listening at
|
||||
// localhost:9050
|
||||
let proxy = Socks5Config::new("127.0.0.1:9050");
|
||||
let config = ConfigBuilder::new().socks5(Some(proxy)).unwrap().build();
|
||||
let config = ConfigBuilder::new().socks5(Some(proxy)).build();
|
||||
|
||||
let client = Client::from_config("tcp://explorernuoc63nb.onion:110", config.clone()).unwrap();
|
||||
let res = client.server_features();
|
||||
|
||||
@ -404,10 +404,7 @@ mod tests {
|
||||
let now = Instant::now();
|
||||
let client = Client::from_config(
|
||||
&endpoint,
|
||||
crate::config::ConfigBuilder::new()
|
||||
.timeout(Some(5))
|
||||
.unwrap()
|
||||
.build(),
|
||||
crate::config::ConfigBuilder::new().timeout(Some(5)).build(),
|
||||
);
|
||||
let elapsed = now.elapsed();
|
||||
|
||||
|
||||
@ -44,15 +44,15 @@ impl ConfigBuilder {
|
||||
|
||||
/// Set the socks5 config if Some, it accept an `Option` because it's easier for the caller to use
|
||||
/// in a method chain
|
||||
pub fn socks5(mut self, socks5_config: Option<Socks5Config>) -> Result<Self, Error> {
|
||||
pub fn socks5(mut self, socks5_config: Option<Socks5Config>) -> Self {
|
||||
self.config.socks5 = socks5_config;
|
||||
Ok(self)
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the timeout
|
||||
pub fn timeout(mut self, timeout: Option<u8>) -> Result<Self, Error> {
|
||||
pub fn timeout(mut self, timeout: Option<u8>) -> Self {
|
||||
self.config.timeout = timeout.map(|t| Duration::from_secs(t as u64));
|
||||
Ok(self)
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the retry attempts number
|
||||
|
||||
Loading…
Reference in New Issue
Block a user