Tell the user about the monero-wallet-rpc download

Fixes #242.
pull/243/head
Thomas Eizinger 3 years ago
parent 06e3bccaa6
commit a82e82edd5
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

7
Cargo.lock generated

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

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

@ -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::<u64>()?;
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,

Loading…
Cancel
Save