diff --git a/Cargo.toml b/Cargo.toml index 59ad2b767..3d80609c2 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ bdk_esplora = { version = "0.22.0", default-features = false, features = ["async bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"]} bdk_wallet = { version = "2.2.0", default-features = false, features = ["std", "keys-bip39"]} -reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } +bitreq = { version = "0.2", default-features = false, features = ["async-https"] } rustls = { version = "0.23", default-features = false } rusqlite = { version = "0.31.0", features = ["bundled"] } bitcoin = "0.32.7" diff --git a/src/gossip.rs b/src/gossip.rs index 563d9e1ea..7a72c9f43 100644 --- a/src/gossip.rs +++ b/src/gossip.rs @@ -92,7 +92,7 @@ impl GossipSource { let response = tokio::time::timeout( Duration::from_secs(RGS_SYNC_TIMEOUT_SECS), - reqwest::get(query_url), + bitreq::get(query_url).send_async(), ) .await .map_err(|e| { @@ -104,15 +104,10 @@ impl GossipSource { Error::GossipUpdateFailed })?; - match response.error_for_status() { - Ok(res) => { - let update_data = res.bytes().await.map_err(|e| { - log_trace!(logger, "Failed to retrieve RGS gossip update: {}", e); - Error::GossipUpdateFailed - })?; - + match response.status_code { + 200 => { let new_latest_sync_timestamp = - gossip_sync.update_network_graph(&update_data).map_err(|e| { + gossip_sync.update_network_graph(response.as_bytes()).map_err(|e| { log_trace!( logger, "Failed to update network graph with RGS data: {:?}", @@ -123,8 +118,8 @@ impl GossipSource { latest_sync_timestamp.store(new_latest_sync_timestamp, Ordering::Release); Ok(new_latest_sync_timestamp) }, - Err(e) => { - log_trace!(logger, "Failed to retrieve RGS gossip update: {}", e); + code => { + log_trace!(logger, "Failed to retrieve RGS gossip update: HTTP {}", code); Err(Error::GossipUpdateFailed) }, } diff --git a/src/scoring.rs b/src/scoring.rs index 6385f2f56..694659ccf 100644 --- a/src/scoring.rs +++ b/src/scoring.rs @@ -56,7 +56,7 @@ async fn sync_external_scores( ) -> () { let response = tokio::time::timeout( Duration::from_secs(EXTERNAL_PATHFINDING_SCORES_SYNC_TIMEOUT_SECS), - reqwest::get(url), + bitreq::get(url).send_async(), ) .await; @@ -74,14 +74,11 @@ async fn sync_external_scores( return; }, }; - let body = match response.bytes().await { - Ok(bytes) => bytes, - Err(e) => { - log_error!(logger, "Failed to read external scores update: {}", e); - return; - }, - }; - let mut reader = Cursor::new(body); + if response.status_code != 200 { + log_trace!(logger, "Failed to retrieve external scores update: HTTP {}", response.status_code); + return; + } + let mut reader = Cursor::new(response.as_bytes()); match ChannelLiquidities::read(&mut reader) { Ok(liquidities) => { if let Err(e) = write_external_pathfinding_scores_to_cache(