From 8b37b2bfee9cd83a89632e3cd28ccf14977b86e3 Mon Sep 17 00:00:00 2001 From: real Date: Thu, 5 Mar 2020 16:20:52 +0200 Subject: [PATCH 1/3] Fixed compilation for aarch64 (Android) --- components/capnp_conv/Cargo.toml | 2 +- components/capnp_conv/src/lib.rs | 3 +++ components/proto/Cargo.toml | 2 +- components/proto/src/lib.rs | 3 +++ components/stctrl/Cargo.toml | 2 +- components/stctrl/src/lib.rs | 3 +++ 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/capnp_conv/Cargo.toml b/components/capnp_conv/Cargo.toml index b516d11eb..451b7633c 100644 --- a/components/capnp_conv/Cargo.toml +++ b/components/capnp_conv/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" log = "0.4" pretty_env_logger = "0.2" -capnp_conv_derive = { path = "capnp_conv_derive", version = "0.1.0", package = "offst-capnp-conv-derive" } +offst-capnp-conv-derive = { path = "capnp_conv_derive", version = "0.1.0" } capnp = "0.10.0" derive_more = "0.15.0" diff --git a/components/capnp_conv/src/lib.rs b/components/capnp_conv/src/lib.rs index 185554e54..f8a2054d6 100644 --- a/components/capnp_conv/src/lib.rs +++ b/components/capnp_conv/src/lib.rs @@ -8,6 +8,9 @@ clippy::new_without_default )] +// Workaround for issue: https://github.com/rust-lang/rust/issues/64450 +extern crate offst_capnp_conv_derive as capnp_conv_derive; + use std::io; use capnp; diff --git a/components/proto/Cargo.toml b/components/proto/Cargo.toml index c5234ce10..68d631b79 100644 --- a/components/proto/Cargo.toml +++ b/components/proto/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] common = { path = "../common", version = "0.1.0", package = "offst-common" } -mutual_from = { path = "../mutual_from", version = "0.1.0", package = "offst-mutual-from" } +offst-mutual-from = { path = "../mutual_from", version = "0.1.0"} capnp_conv = { path = "../capnp_conv", version = "0.1.0", package = "offst-capnp-conv" } capnp = "0.10.0" diff --git a/components/proto/src/lib.rs b/components/proto/src/lib.rs index 96470058e..9d215ebe1 100644 --- a/components/proto/src/lib.rs +++ b/components/proto/src/lib.rs @@ -10,6 +10,9 @@ #[macro_use] extern crate quickcheck_derive; +// Workaround for issue: https://github.com/rust-lang/rust/issues/64450 +extern crate offst_mutual_from as mutual_from; + #[macro_use] pub mod macros; pub mod app_server; diff --git a/components/stctrl/Cargo.toml b/components/stctrl/Cargo.toml index b96241256..841016b45 100644 --- a/components/stctrl/Cargo.toml +++ b/components/stctrl/Cargo.toml @@ -22,7 +22,7 @@ path = "src/bin/stverify.rs" route = { path = "../route", version = "0.1.0", package = "offst-route" } app = { path = "../app", version = "0.1.0", package = "offst-app" } -mutual_from = { path = "../mutual_from", version = "0.1.0", package = "offst-mutual-from" } +offst-mutual-from = { path = "../mutual_from", version = "0.1.0"} log = "0.4" diff --git a/components/stctrl/src/lib.rs b/components/stctrl/src/lib.rs index 0f09623d8..b783ab855 100644 --- a/components/stctrl/src/lib.rs +++ b/components/stctrl/src/lib.rs @@ -9,6 +9,9 @@ // TODO; Remove this hint: #![allow(unused)] +// Workaround for issue: https://github.com/rust-lang/rust/issues/64450 +extern crate offst_mutual_from as mutual_from; + #[macro_use] extern crate prettytable; From b87cf938b8102475c2cabe48745bb60ec07b6cec Mon Sep 17 00:00:00 2001 From: real Date: Thu, 5 Mar 2020 16:30:59 +0200 Subject: [PATCH 2/3] stctrl: Removed 'allow unused' hint --- components/stctrl/src/buyer.rs | 21 +++++++++------------ components/stctrl/src/config.rs | 2 +- components/stctrl/src/file.rs | 2 +- components/stctrl/src/info.rs | 6 +++--- components/stctrl/src/lib.rs | 2 -- components/stctrl/src/seller.rs | 2 +- components/stctrl/src/stctrllib.rs | 2 +- components/stctrl/src/stverifylib.rs | 4 ++-- 8 files changed, 18 insertions(+), 23 deletions(-) diff --git a/components/stctrl/src/buyer.rs b/components/stctrl/src/buyer.rs index 6e77370e8..0f9b67986 100644 --- a/components/stctrl/src/buyer.rs +++ b/components/stctrl/src/buyer.rs @@ -5,19 +5,16 @@ use std::path::PathBuf; use derive_more::From; -use futures::future::select_all; use futures::sink::SinkExt; use futures::stream::StreamExt; use structopt::StructOpt; use app::common::{ - Commit, Currency, InvoiceId, MultiRoute, PaymentId, PaymentStatus, PaymentStatusSuccess, - PublicKey, Uid, + Currency, InvoiceId, MultiRoute, PaymentId, PaymentStatus, PaymentStatusSuccess, PublicKey, Uid, }; use app::conn::{ - self, buyer, routes, AppServerToApp, AppToAppServer, ConnPairApp, RequestResult, - ResponseRoutesResult, + self, AppServerToApp, AppToAppServer, ConnPairApp, RequestResult, ResponseRoutesResult, }; use app::gen::{gen_payment_id, gen_uid}; use app::report::NodeReport; @@ -122,7 +119,7 @@ async fn request_routes( .sender .send(app_to_app_server) .await - .map_err(|_| BuyerError::AppRoutesError); + .map_err(|_| BuyerError::AppRoutesError)?; // Wait until we get back response routes: while let Some(app_server_to_app) = conn_pair.receiver.next().await { @@ -163,7 +160,7 @@ async fn create_payment( .sender .send(app_to_app_server) .await - .map_err(|_| BuyerError::CreatePaymentFailed); + .map_err(|_| BuyerError::CreatePaymentFailed)?; while let Some(app_server_to_app) = conn_pair.receiver.next().await { if let AppServerToApp::ReportMutations(report_mutations) = app_server_to_app { @@ -196,7 +193,7 @@ async fn request_close_payment_nowait( .sender .send(app_to_app_server) .await - .map_err(|_| BuyerError::RequestClosePaymentError); + .map_err(|_| BuyerError::RequestClosePaymentError)?; while let Some(app_server_to_app) = conn_pair.receiver.next().await { if let AppServerToApp::ReportMutations(report_mutations) = app_server_to_app { @@ -229,7 +226,7 @@ async fn request_close_payment( .sender .send(app_to_app_server) .await - .map_err(|_| BuyerError::RequestClosePaymentError); + .map_err(|_| BuyerError::RequestClosePaymentError)?; while let Some(app_server_to_app) = conn_pair.receiver.next().await { if let AppServerToApp::ResponseClosePayment(response_close_payment) = app_server_to_app { @@ -261,7 +258,7 @@ async fn ack_close_payment( .sender .send(app_to_app_server) .await - .map_err(|_| BuyerError::AckClosePaymentError); + .map_err(|_| BuyerError::AckClosePaymentError)?; while let Some(app_server_to_app) = conn_pair.receiver.next().await { if let AppServerToApp::ReportMutations(report_mutations) = app_server_to_app { @@ -377,7 +374,7 @@ async fn buyer_pay_invoice( .sender .send(app_to_app_server) .await - .map_err(|_| BuyerError::CreateTransactionFailed); + .map_err(|_| BuyerError::CreateTransactionFailed)?; } // Signal that no new transactions will be created: @@ -482,7 +479,7 @@ async fn buyer_payment_status( pub async fn buyer( buyer_cmd: BuyerCmd, node_report: &NodeReport, - mut conn_pair: ConnPairApp, + conn_pair: ConnPairApp, writer: &mut impl io::Write, ) -> Result<(), BuyerError> { // Get our local public key: diff --git a/components/stctrl/src/config.rs b/components/stctrl/src/config.rs index 65bc86be4..42639d217 100644 --- a/components/stctrl/src/config.rs +++ b/components/stctrl/src/config.rs @@ -272,7 +272,7 @@ async fn config_request( .sender .send(app_to_app_server) .await - .map_err(|_| ConfigError::AppConfigError); + .map_err(|_| ConfigError::AppConfigError)?; // Wait until we get an ack for our request: while let Some(app_server_to_app) = conn_pair.receiver.next().await { diff --git a/components/stctrl/src/file.rs b/components/stctrl/src/file.rs index 9b1d67584..577203a4c 100644 --- a/components/stctrl/src/file.rs +++ b/components/stctrl/src/file.rs @@ -5,7 +5,6 @@ use app::common::{ RandValue, Receipt, Signature, }; use app::report::{MoveTokenHashedReport, TokenInfo}; -use app::ser_utils::serialize_to_string; use mutual_from::mutual_from; @@ -93,6 +92,7 @@ mod test { use std::convert::TryFrom; use app::report::{BalanceInfo, CountersInfo, CurrencyBalanceInfo, McInfo}; + use app::ser_utils::serialize_to_string; #[test] fn test_serialize_invoice_file() { diff --git a/components/stctrl/src/info.rs b/components/stctrl/src/info.rs index fda3806e2..c79df96a1 100644 --- a/components/stctrl/src/info.rs +++ b/components/stctrl/src/info.rs @@ -10,12 +10,10 @@ use derive_more::From; use app::common::RelayAddress; use app::report::{ ChannelStatusReport, CurrencyReport, FriendReport, FriendStatusReport, NodeReport, - RequestsStatusReport, }; use app::ser_utils::public_key_to_string; -use app::conn::ConnPairApp; -use app::file::{FriendAddressFile, FriendFile, RelayAddressFile}; +use app::file::{FriendAddressFile, RelayAddressFile}; use app::ser_utils::{serialize_to_string, StringSerdeError}; use crate::file::TokenFile; @@ -190,6 +188,7 @@ pub async fn info_index( Ok(()) } +/* /// Return a string that represents requests status. /// "+" means open, "-" means closed fn requests_status_str(requests_status_report: &RequestsStatusReport) -> String { @@ -200,6 +199,7 @@ fn requests_status_str(requests_status_report: &RequestsStatusReport) -> String } .to_owned() } +*/ /* /// Check if a friend state is consistent diff --git a/components/stctrl/src/lib.rs b/components/stctrl/src/lib.rs index b783ab855..88f85f136 100644 --- a/components/stctrl/src/lib.rs +++ b/components/stctrl/src/lib.rs @@ -6,8 +6,6 @@ clippy::module_inception, clippy::new_without_default )] -// TODO; Remove this hint: -#![allow(unused)] // Workaround for issue: https://github.com/rust-lang/rust/issues/64450 extern crate offst_mutual_from as mutual_from; diff --git a/components/stctrl/src/seller.rs b/components/stctrl/src/seller.rs index fdb7705f9..d5cc19081 100644 --- a/components/stctrl/src/seller.rs +++ b/components/stctrl/src/seller.rs @@ -100,7 +100,7 @@ async fn seller_request( .sender .send(app_to_app_server) .await - .map_err(|_| SellerError::SellerRequestError); + .map_err(|_| SellerError::SellerRequestError)?; // Wait until we get an ack for our request: while let Some(app_server_to_app) = conn_pair.receiver.next().await { diff --git a/components/stctrl/src/stctrllib.rs b/components/stctrl/src/stctrllib.rs index 76239808d..0878e0b45 100644 --- a/components/stctrl/src/stctrllib.rs +++ b/components/stctrl/src/stctrllib.rs @@ -69,7 +69,7 @@ pub struct StCtrlCmd { } pub fn stctrl(st_ctrl_cmd: StCtrlCmd, writer: &mut impl io::Write) -> Result<(), StCtrlError> { - let mut thread_pool = ThreadPool::new().map_err(|_| StCtrlError::CreateThreadPoolError)?; + let thread_pool = ThreadPool::new().map_err(|_| StCtrlError::CreateThreadPoolError)?; let StCtrlCmd { idfile, diff --git a/components/stctrl/src/stverifylib.rs b/components/stctrl/src/stverifylib.rs index f7fedc8f7..80cff27da 100644 --- a/components/stctrl/src/stverifylib.rs +++ b/components/stctrl/src/stverifylib.rs @@ -1,5 +1,5 @@ use std::fs; -use std::io::{self, Write}; +use std::io; use std::path::PathBuf; use derive_more::From; @@ -109,7 +109,7 @@ fn stverify_verify_token( ) .map_err(|_| StVerifyError::WriteError)?; - writeln!(writer, "balances:\n"); + writeln!(writer, "balances:\n").map_err(|_| StVerifyError::WriteError)?; for currency_balance_info in move_token_hashed_report.token_info.mc.balances { let balance_info = ¤cy_balance_info.balance_info; From 14860d14d7ffd4e25a7e21312b3dbb65f1aec966 Mon Sep 17 00:00:00 2001 From: real Date: Thu, 5 Mar 2020 16:56:40 +0200 Subject: [PATCH 3/3] common: Fixed bug in 32 bit compilation at usize_to_u32() --- components/common/src/int_convert.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/common/src/int_convert.rs b/components/common/src/int_convert.rs index b69923c2c..3bee76665 100644 --- a/components/common/src/int_convert.rs +++ b/components/common/src/int_convert.rs @@ -6,7 +6,7 @@ use std::u32; target_pointer_width = "32" ))] pub fn usize_to_u32(num: usize) -> Option { - Some(a as u32) + Some(num as u32) } #[cfg(target_pointer_width = "64")]