Skip to content

Commit

Permalink
- Conditional compilation was added to exclude store_forward Tokio …
Browse files Browse the repository at this point in the history
…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 <pluto@tari.com>
  • Loading branch information
hansieodendaal committed Mar 6, 2020
1 parent c5fa657 commit 2b75d32
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 21 deletions.
14 changes: 13 additions & 1 deletion base_layer/wallet/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# Tari Wallet
# 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
10 changes: 10 additions & 0 deletions base_layer/wallet_ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 19 additions & 12 deletions comms/dht/src/dht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down
23 changes: 15 additions & 8 deletions infrastructure/storage/tests/lmdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<User> {
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<User>, LMDBDatabase) {
Expand Down

0 comments on commit 2b75d32

Please sign in to comment.