From 2b75d3272b4f28be8dff8a5b14124436d9f922a7 Mon Sep 17 00:00:00 2001 From: Hansie Odendaal Date: Wed, 4 Mar 2020 14:18:13 +0200 Subject: [PATCH] - Conditional compilation was added to exclude `store_forward` Tokio layer to be added for Windows builds. This removes `store_forward` functionality from Windpows, but provides a temporary fix. - Small refactoring for `fn load_users()` in `lmdb.rs` - Windows build and run instructions where SQLite is a dependency Signed-off-by: Hansie Odendaal --- base_layer/wallet/README.md | 14 ++++++++++++- base_layer/wallet_ffi/README.md | 10 +++++++++ comms/dht/src/dht.rs | 31 +++++++++++++++++----------- infrastructure/storage/tests/lmdb.rs | 23 ++++++++++++++------- 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/base_layer/wallet/README.md b/base_layer/wallet/README.md index 0158fd19a3..8448d4d4b0 100644 --- a/base_layer/wallet/README.md +++ b/base_layer/wallet/README.md @@ -1 +1,13 @@ -# Tari Wallet \ No newline at end of file +# Tari Wallet + +Foreign Function interface for the Tari Android and Tari iOS Wallets. + +This crate is part of the [Tari Cryptocurrency](https://tari.com) project. + +## Build setup (Mac) + +See README.md in wallet_ffi crate + +## Setup (Windows) + +See README.md in wallet_ffi crate diff --git a/base_layer/wallet_ffi/README.md b/base_layer/wallet_ffi/README.md index 37e53154a4..82a18d1a7d 100644 --- a/base_layer/wallet_ffi/README.md +++ b/base_layer/wallet_ffi/README.md @@ -114,3 +114,13 @@ sh mobile_build.sh The relevant libraries will then be built and placed in the appropriate directories of the Wallet-iOS and Wallet-Android repositories. +# Setup (Windows) + +## Test + +1. Download SQL Lite (https://www.sqlite.org/index.html - 64bit) and unzip +2. `sqlite3.dll` must be accessible via the session path + +## Build + +ToDo - Android only diff --git a/comms/dht/src/dht.rs b/comms/dht/src/dht.rs index efced7265d..5d1b8c65e0 100644 --- a/comms/dht/src/dht.rs +++ b/comms/dht/src/dht.rs @@ -161,8 +161,7 @@ impl Dht { let saf_storage = Arc::new(store_forward::SafStorage::new( self.config.saf_msg_cache_storage_capacity, )); - - ServiceBuilder::new() + let builder = ServiceBuilder::new() .layer(inbound::DeserializeLayer::new()) .layer(inbound::ValidateLayer::new( self.config.network, @@ -174,7 +173,12 @@ impl Dht { .layer(store_forward::ForwardLayer::new( Arc::clone(&self.peer_manager), self.outbound_requester(), - )) + )); + + // FIXME: The store and forward layers are excluded for Windows builds due to an unresolved stack overflow + // (#1416) + #[cfg(not(target_os = "windows"))] + let builder = builder .layer(store_forward::StoreLayer::new( self.config.clone(), Arc::clone(&self.peer_manager), @@ -188,15 +192,16 @@ impl Dht { Arc::clone(&self.node_identity), Arc::clone(&self.peer_manager), self.outbound_requester(), - )) - .layer(inbound::DhtHandlerLayer::new( - self.config.clone(), - Arc::clone(&self.node_identity), - Arc::clone(&self.peer_manager), - self.discovery_service_requester(), - self.outbound_requester(), - )) - .into_inner() + )); + + let builder = builder.layer(inbound::DhtHandlerLayer::new( + self.config.clone(), + Arc::clone(&self.node_identity), + Arc::clone(&self.peer_manager), + self.discovery_service_requester(), + self.outbound_requester(), + )); + builder.into_inner() } /// Returns an the full DHT stack as a `tower::layer::Layer`. This can be composed with @@ -363,6 +368,8 @@ mod test { assert_eq!(msg, b"secret"); } + // FIXME: This test is excluded for Windows builds due to an unresolved stack overflow issue (#1416) + #[cfg(not(target_os = "windows"))] #[tokio_macros::test_basic] async fn stack_forward() { let node_identity = make_node_identity(); diff --git a/infrastructure/storage/tests/lmdb.rs b/infrastructure/storage/tests/lmdb.rs index 17efd1f284..211903a59d 100644 --- a/infrastructure/storage/tests/lmdb.rs +++ b/infrastructure/storage/tests/lmdb.rs @@ -21,7 +21,15 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use serde::{Deserialize, Serialize}; -use std::{net::Ipv4Addr, path::PathBuf, str::FromStr, sync::Arc, thread}; +use std::{ + fs::File, + io::{BufRead, BufReader}, + net::Ipv4Addr, + path::PathBuf, + str::FromStr, + sync::Arc, + thread, +}; use tari_storage::{ lmdb_store::{db, LMDBBuilder, LMDBDatabase, LMDBError, LMDBStore}, IterationResult, @@ -94,16 +102,15 @@ fn clean_up(name: &str) { std::fs::remove_dir_all(get_path(name)).unwrap(); } -#[cfg(windows)] -const LINE_ENDING: &str = "\r\n"; -#[cfg(not(windows))] -const LINE_ENDING: &str = "\n"; - fn load_users() -> Vec { let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); path.push("tests/users.csv"); - let f = std::fs::read_to_string(path).unwrap(); - f.split(LINE_ENDING).map(|s| User::new(s).unwrap()).collect() + let file = File::open(path).unwrap(); + BufReader::new(file) + .lines() // `BufReader::lines` is platform agnostic, recognises both `\r\n` and `\n` + .map(|result| result.unwrap()) + .map(|s| User::new(&s).unwrap()) + .collect() } fn insert_all_users(name: &str) -> (Vec, LMDBDatabase) {