Skip to content

Tokio + Reqwest upgrade #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,047 changes: 1,273 additions & 774 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ grin_wallet_util = { path = "./util", version = "5.4.0-alpha.1" }
##### Grin Imports

# For Release
grin_core = "5.3.3"
grin_keychain = "5.3.3"
grin_util = "5.3.3"
grin_api = "5.3.3"
# grin_core = "5.3.3"
# grin_keychain = "5.3.3"
# grin_util = "5.3.3"
# grin_api = "5.3.3"

# For beta release

Expand All @@ -54,10 +54,10 @@ grin_api = "5.3.3"
# grin_api = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }

# For bleeding edge
# grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_api = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_api = { git = "https://github.com/mimblewimble/grin", branch = "master" }

# For local testing
# grin_core = { path = "../grin/core"}
Expand All @@ -76,4 +76,5 @@ serde = "1"
serde_derive = "1"
serde_json = "1"
remove_dir_all = "0.7"
easy-jsonrpc-mw = "0.5.4"
easy-jsonrpc-mw = "0.5.4"

12 changes: 6 additions & 6 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ grin_wallet_util = { path = "../util", version = "5.4.0-alpha.1" }
##### Grin Imports

# For Release
grin_core = "5.3.3"
grin_keychain = "5.3.3"
grin_util = "5.3.3"
# grin_core = "5.3.3"
# grin_keychain = "5.3.3"
# grin_util = "5.3.3"

# For beta release

Expand All @@ -41,9 +41,9 @@ grin_util = "5.3.3"
# grin_util = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }

# For bleeding edge
# grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }

# For local testing
# grin_core = { path = "../../grin/core"}
Expand Down
12 changes: 6 additions & 6 deletions config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ grin_wallet_util = { path = "../util", version = "5.4.0-alpha.1" }
##### Grin Imports

# For Release
grin_core = "5.3.3"
grin_util = "5.3.3"
# grin_core = "5.3.3"
# grin_util = "5.3.3"

# For beta release

#grin_core = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3"}
#grin_util = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }
# grin_core = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3"}
# grin_util = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }

# For bleeding edge
# grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }

# For local testing
# grin_core = { path = "../../grin/core"}
Expand Down
9 changes: 4 additions & 5 deletions config/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,9 @@ pub fn migrate_comments(
None
}
false => {
let comments: String =
vec_old_conf.iter().map(|s| s.chars()).flatten().collect();
let comments: String = vec_old_conf.iter().flat_map(|s| s.chars()).collect();
let key = get_key(line_nospace);
match !(key == "NOT_FOUND") {
match key != "NOT_FOUND" {
true => {
vec_old_conf.clear();
hm_key_cmt_old.insert(key.clone(), comments);
Expand All @@ -356,10 +355,10 @@ pub fn migrate_comments(
.filter_map(|line| {
let line_nospace = line.trim();
let is_ascii_control = line_nospace.chars().all(|x| x.is_ascii_control());
match !(line.contains("#") || is_ascii_control) {
match !line.contains("#") && !is_ascii_control {
true => {
let key = get_key(line_nospace);
match !(key == "NOT_FOUND") {
match key != "NOT_FOUND" {
true => Some((key, line_nospace.to_string())),
false => None,
}
Expand Down
20 changes: 10 additions & 10 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::env;
use std::fs::{self, File};
use std::io::prelude::*;
use std::io::BufReader;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use toml;

use crate::comments::{insert_comments, migrate_comments};
Expand Down Expand Up @@ -211,7 +211,7 @@ impl GlobalWalletConfig {
pub fn for_chain(chain_type: &global::ChainTypes) -> GlobalWalletConfig {
let mut defaults_conf = GlobalWalletConfig::default();
let defaults = &mut defaults_conf.members.as_mut().unwrap().wallet;
defaults.chain_type = Some(chain_type.clone());
defaults.chain_type = Some(*chain_type);

match *chain_type {
global::ChainTypes::Mainnet => {}
Expand Down Expand Up @@ -268,20 +268,20 @@ impl GlobalWalletConfig {
}

/// Update paths
pub fn update_paths(&mut self, wallet_home: &PathBuf) {
let mut wallet_path = wallet_home.clone();
pub fn update_paths(&mut self, wallet_home: &Path) {
let mut wallet_path = wallet_home.to_path_buf();
wallet_path.push(GRIN_WALLET_DIR);
self.members.as_mut().unwrap().wallet.data_file_dir =
wallet_path.to_str().unwrap().to_owned();
let mut secret_path = wallet_home.clone();
let mut secret_path = wallet_home.to_path_buf();
secret_path.push(OWNER_API_SECRET_FILE_NAME);
self.members.as_mut().unwrap().wallet.api_secret_path =
Some(secret_path.to_str().unwrap().to_owned());
let mut node_secret_path = wallet_home.clone();
let mut node_secret_path = wallet_home.to_path_buf();
node_secret_path.push(API_SECRET_FILE_NAME);
self.members.as_mut().unwrap().wallet.node_api_secret_path =
Some(node_secret_path.to_str().unwrap().to_owned());
let mut log_path = wallet_home.clone();
let mut log_path = wallet_home.to_path_buf();
log_path.push(WALLET_LOG_FILE_NAME);
self.members
.as_mut()
Expand All @@ -290,7 +290,7 @@ impl GlobalWalletConfig {
.as_mut()
.unwrap()
.log_file_path = log_path.to_str().unwrap().to_owned();
let tor_path = wallet_home.clone();
let tor_path = wallet_home.to_path_buf();
self.members
.as_mut()
.unwrap()
Expand Down Expand Up @@ -339,15 +339,15 @@ impl GlobalWalletConfig {
) -> Result<String, ConfigError> {
let config: GlobalWalletConfigMembers =
toml::from_str(&GlobalWalletConfig::fix_warning_level(config_str.clone())).unwrap();
if config.config_file_version != None {
if config.config_file_version.is_some() {
return Ok(config_str);
}
let adjusted_config = GlobalWalletConfigMembers {
config_file_version: GlobalWalletConfigMembers::default().config_file_version,
tor: Some(TorConfig {
bridge: TorBridgeConfig::default(),
proxy: TorProxyConfig::default(),
..config.tor.unwrap_or(TorConfig::default())
..config.tor.unwrap_or_default()
}),
..config
};
Expand Down
27 changes: 3 additions & 24 deletions config/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl WalletConfig {
/// Accept fee base
pub fn accept_fee_base(&self) -> u64 {
self.accept_fee_base
.unwrap_or_else(|| WalletConfig::default_accept_fee_base())
.unwrap_or_else(WalletConfig::default_accept_fee_base)
}
}
/// Error type wrapping config errors.
Expand Down Expand Up @@ -192,31 +192,22 @@ impl Default for TorConfig {
}

/// Tor Bridge Config
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct TorBridgeConfig {
/// Bridge Line
pub bridge_line: Option<String>,
/// Client Option
pub client_option: Option<String>,
}

impl Default for TorBridgeConfig {
fn default() -> TorBridgeConfig {
TorBridgeConfig {
bridge_line: None,
client_option: None,
}
}
}

impl fmt::Display for TorBridgeConfig {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}

/// Tor Proxy configuration (useful for protocols such as shadowsocks)
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct TorProxyConfig {
/// socks4 |socks5 | http(s)
pub transport: Option<String>,
Expand All @@ -230,18 +221,6 @@ pub struct TorProxyConfig {
pub allowed_port: Option<Vec<u16>>,
}

impl Default for TorProxyConfig {
fn default() -> TorProxyConfig {
TorProxyConfig {
transport: None,
address: None,
username: None,
password: None,
allowed_port: None,
}
}
}

impl fmt::Display for TorProxyConfig {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
Expand Down
24 changes: 12 additions & 12 deletions controller/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2018"

[dependencies]
futures = "0.3"
hyper = "0.13"
hyper = "0.14"
rand = "0.7"
serde = "1"
serde_derive = "1"
Expand All @@ -21,7 +21,7 @@ log = "0.4"
prettytable-rs = "0.10"
ring = "0.16"
term = "0.6"
tokio = { version = "0.2", features = ["full"] }
tokio = { version = "1", features = ["full"] }
uuid = { version = "0.8", features = ["serde", "v4"] }
url = "2.1"
chrono = { version = "0.4.11", features = ["serde"] }
Expand All @@ -39,10 +39,10 @@ grin_wallet_config = { path = "../config", version = "5.4.0-alpha.1" }
##### Grin Imports

# For Release
grin_core = "5.3.3"
grin_keychain = "5.3.3"
grin_util = "5.3.3"
grin_api = "5.3.3"
# grin_core = "5.3.3"
# grin_keychain = "5.3.3"
# grin_util = "5.3.3"
# grin_api = "5.3.3"

# For beta release

Expand All @@ -52,10 +52,10 @@ grin_api = "5.3.3"
# grin_api = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }

# For bleeding edge
# grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_api = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_api = { git = "https://github.com/mimblewimble/grin", branch = "master" }

# For local testing
# grin_core = { path = "../../grin/core"}
Expand All @@ -72,14 +72,14 @@ remove_dir_all = "0.7"
##### Grin Imports

# For Release
grin_chain = "5.3.3"
# grin_chain = "5.3.3"

# For beta release

# grin_chain = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }

# For bleeding edge
# grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "master" }

# For local testing
# grin_chain = { path = "../../grin/chain"}
Expand Down
4 changes: 2 additions & 2 deletions controller/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use futures::channel::oneshot;
use grin_wallet_api::JsonId;
use grin_wallet_config::types::{TorBridgeConfig, TorProxyConfig};
use grin_wallet_util::OnionV3Address;
use hyper::body;
use hyper::body::to_bytes;
use hyper::header::HeaderValue;
use hyper::{Body, Request, Response, StatusCode};
use qr_code::QrCode;
Expand Down Expand Up @@ -866,7 +866,7 @@ async fn parse_body<T>(req: Request<Body>) -> Result<T, Error>
where
for<'de> T: Deserialize<'de> + Send + 'static,
{
let body = body::to_bytes(req.into_body())
let body = to_bytes(req.into_body())
.await
.map_err(|_| Error::GenericError("Failed to read request".to_string()))?;

Expand Down
28 changes: 14 additions & 14 deletions impls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ ring = "0.16"
uuid = { version = "0.8", features = ["serde", "v4"] }
chrono = { version = "0.4.11", features = ["serde"] }
lazy_static = "1"
tokio = { version = "0.2", features = ["full"] }
reqwest = { version = "0.10", features = ["rustls-tls", "socks"] }
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.12", features = ["rustls-tls", "socks"] }

#Socks/Tor/Bridge/Proxy
byteorder = "1"
Expand All @@ -43,12 +43,12 @@ grin_wallet_libwallet = { path = "../libwallet", version = "5.4.0-alpha.1" }
##### Grin Imports

# For Release
grin_core = "5.3.3"
grin_keychain = "5.3.3"
grin_chain = "5.3.3"
grin_util = "5.3.3"
grin_api = "5.3.3"
grin_store = "5.3.3"
# grin_core = "5.3.3"
# grin_keychain = "5.3.3"
# grin_chain = "5.3.3"
# grin_util = "5.3.3"
# grin_api = "5.3.3"
# grin_store = "5.3.3"

# For beta release

Expand All @@ -60,12 +60,12 @@ grin_store = "5.3.3"
# grin_store = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }

# For bleeding edge
# grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_api = { git = "https://github.com/mimblewimble/grin", branch = "master" }
# grin_store = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_keychain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_chain = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_util = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_api = { git = "https://github.com/mimblewimble/grin", branch = "master" }
grin_store = { git = "https://github.com/mimblewimble/grin", branch = "master" }

# For local testing
# grin_core = { path = "../../grin/core"}
Expand Down
11 changes: 2 additions & 9 deletions impls/src/client_utils/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,10 @@ use std::time::Duration;
use tokio::runtime::{Builder, Handle, Runtime};

// Global Tokio runtime.
// Needs a `Mutex` because `Runtime::block_on` requires mutable access.
// Tokio v0.3 requires immutable self, but we are waiting on upstream
// updates before we can upgrade.
// See: https://github.com/seanmonstar/reqwest/pull/1076
// With tokio 1.0, Runtime::block_on no longer requires mutable access
lazy_static! {
pub static ref RUNTIME: Arc<Mutex<Runtime>> = Arc::new(Mutex::new(
Builder::new()
.threaded_scheduler()
.enable_all()
.build()
.unwrap()
Builder::new_multi_thread().enable_all().build().unwrap()
));
}

Expand Down
Loading