From 08923a14f3d56cedff90d46f97ecfbdf91c9241a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 5 Mar 2021 17:06:17 +1100 Subject: [PATCH] Simplify GET request for block tip height --- swap/src/bitcoin/wallet.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index d019d578..b73dd666 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -12,7 +12,7 @@ use bdk::electrum_client::{self, Client, ElectrumApi}; use bdk::keys::DerivableKey; use bdk::{FeeRate, KeychainKind}; use bitcoin::Script; -use reqwest::{Method, Url}; +use reqwest::Url; use serde::{Deserialize, Serialize}; use std::path::Path; use std::sync::Arc; @@ -226,10 +226,9 @@ impl Wallet { pub async fn get_block_height(&self) -> Result { let url = make_blocks_tip_height_url(&self.http_url)?; + let height = retry(ConstantBackoff::new(Duration::from_secs(1)), || async { - let height = reqwest::Client::new() - .request(Method::GET, url.clone()) - .send() + let height = reqwest::get(url.clone()) .await .map_err(Error::Io)? .text()