Tell the user about the monero-wallet-rpc download

Fixes #242.
This commit is contained in:
Thomas Eizinger 2021-03-01 11:46:53 +11:00
parent 06e3bccaa6
commit a82e82edd5
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
3 changed files with 26 additions and 3 deletions

View file

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