diff --git a/Cargo.lock b/Cargo.lock index 7c7da167..bc6a00c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -302,6 +302,12 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdcf67bb7ba7797a081cd19009948ab533af7c355d5caf1d08c777582d351e9c" +[[package]] +name = "big-bytes" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d73a8ae8ce52d09395e4cafc83b5b81c3deb70a97740e907669c8683c4dd50a" + [[package]] name = "bincode" version = "1.3.1" @@ -3525,6 +3531,7 @@ dependencies = [ "backoff", "base64 0.12.3", "bdk", + "big-bytes", "bitcoin", "bitcoin-harness", "config", diff --git a/swap/Cargo.toml b/swap/Cargo.toml index 73f926d3..8a615b3a 100644 --- a/swap/Cargo.toml +++ b/swap/Cargo.toml @@ -20,6 +20,7 @@ atty = "0.2" backoff = { version = "0.3", features = ["tokio"] } base64 = "0.12" bdk = { version = "0.4" } +big-bytes = "1" bitcoin = { version = "0.26", features = ["rand", "use-serde"] } config = { version = "0.10", default-features = false, features = ["toml"] } conquer-once = "0.3" diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index 82328210..2cfe1324 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -1,8 +1,9 @@ use ::monero::Network; use anyhow::{Context, Result}; use async_compression::tokio::bufread::BzDecoder; +use big_bytes::BigByte; use futures::{StreamExt, TryStreamExt}; -use reqwest::Url; +use reqwest::{header::CONTENT_LENGTH, Url}; use std::{ io::ErrorKind, path::{Path, PathBuf}, @@ -71,8 +72,19 @@ impl WalletRpc { .open(monero_wallet_rpc.tar_path()) .await?; - let byte_stream = reqwest::get(DOWNLOAD_URL) - .await? + let response = reqwest::get(DOWNLOAD_URL).await?; + + let content_length = response.headers()[CONTENT_LENGTH] + .to_str() + .context("failed to convert content-length to string")? + .parse::()?; + + tracing::info!( + "Downloading monero-wallet-rpc ({})", + content_length.big_byte(2) + ); + + let byte_stream = response .bytes_stream() .map_err(|err| std::io::Error::new(ErrorKind::Other, err)); @@ -119,6 +131,8 @@ impl WalletRpc { .local_addr()? .port(); + tracing::debug!("Starting monero-wallet-rpc on port {}", port); + let mut child = Command::new(self.exec_path()) .stdout(Stdio::piped()) .kill_on_drop(true) @@ -148,6 +162,7 @@ impl WalletRpc { break; } } + Ok(WalletRpcProcess { _child: child, port,