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 after 7493630ed8

ACKs for top commit:
  afilini:
    ACK 561db261d3

Tree-SHA512: 7654cfbbc7beac6acec786060e373bbc046e1dae0faf2b2ca1df33121e9e92a8f4950c7f8775e44226a62483aeae41c76162cf037ce38137c44d2fedd38560c8
This commit is contained in:
Alekos Filini 2022-09-13 18:36:52 +02:00
commit 129081999c
No known key found for this signature in database
GPG Key ID: 431401E4A4530061
3 changed files with 6 additions and 9 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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