Show syncing progress at startup
This commit is contained in:
4
lib/Cargo.lock
generated
4
lib/Cargo.lock
generated
@@ -1051,7 +1051,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=6dc22e4d74e9cec458d279d793477dea3bfe27e5)",
|
||||
"zecwalletlitelib 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2266,7 +2266,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "zecwalletlitelib"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=6dc22e4d74e9cec458d279d793477dea3bfe27e5#6dc22e4d74e9cec458d279d793477dea3bfe27e5"
|
||||
dependencies = [
|
||||
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bellman 0.1.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)",
|
||||
@@ -2562,4 +2561,3 @@ dependencies = [
|
||||
"checksum zcash_client_backend 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
||||
"checksum zcash_primitives 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
||||
"checksum zcash_proofs 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
|
||||
"checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=6dc22e4d74e9cec458d279d793477dea3bfe27e5)" = "<none>"
|
||||
|
||||
@@ -11,4 +11,4 @@ crate-type = ["staticlib"]
|
||||
[dependencies]
|
||||
libc = "0.2.58"
|
||||
lazy_static = "1.4.0"
|
||||
zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "6dc22e4d74e9cec458d279d793477dea3bfe27e5" }
|
||||
zecwalletlitelib = { path="../../lightwallet/lightwalletclient/lib/" }
|
||||
|
||||
@@ -4,7 +4,7 @@ extern crate lazy_static;
|
||||
use libc::{c_char};
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::sync::{Mutex};
|
||||
use std::sync::{Mutex, Arc};
|
||||
use std::cell::RefCell;
|
||||
|
||||
use zecwalletlitelib::{commands, lightclient::{LightClient, LightClientConfig}};
|
||||
@@ -13,7 +13,7 @@ use zecwalletlitelib::{commands, lightclient::{LightClient, LightClientConfig}};
|
||||
// so we don't have to keep creating it. We need to store it here, in rust
|
||||
// because we can't return such a complex structure back to C++
|
||||
lazy_static! {
|
||||
static ref LIGHTCLIENT: Mutex<RefCell<Option<LightClient>>> = Mutex::new(RefCell::new(None));
|
||||
static ref LIGHTCLIENT: Mutex<RefCell<Option<Arc<LightClient>>>> = Mutex::new(RefCell::new(None));
|
||||
}
|
||||
|
||||
// Check if there is an existing wallet
|
||||
@@ -65,7 +65,7 @@ pub extern fn litelib_initialize_new(dangerous: bool, server: *const c_char) ->
|
||||
}
|
||||
};
|
||||
|
||||
LIGHTCLIENT.lock().unwrap().replace(Some(lightclient));
|
||||
LIGHTCLIENT.lock().unwrap().replace(Some(Arc::new(lightclient)));
|
||||
|
||||
// Return the wallet's seed
|
||||
let s_str = CString::new(seed).unwrap();
|
||||
@@ -113,7 +113,7 @@ pub extern fn litelib_initialize_new_from_phrase(dangerous: bool, server: *const
|
||||
}
|
||||
};
|
||||
|
||||
LIGHTCLIENT.lock().unwrap().replace(Some(lightclient));
|
||||
LIGHTCLIENT.lock().unwrap().replace(Some(Arc::new(lightclient)));
|
||||
|
||||
let c_str = CString::new("OK").unwrap();
|
||||
return c_str.into_raw();
|
||||
@@ -145,7 +145,7 @@ pub extern fn litelib_initialize_existing(dangerous: bool, server: *const c_char
|
||||
}
|
||||
};
|
||||
|
||||
LIGHTCLIENT.lock().unwrap().replace(Some(lightclient));
|
||||
LIGHTCLIENT.lock().unwrap().replace(Some(Arc::new(lightclient)));
|
||||
|
||||
let c_str = CString::new("OK").unwrap();
|
||||
return c_str.into_raw();
|
||||
@@ -167,16 +167,21 @@ pub extern fn litelib_execute(cmd: *const c_char, args: *const c_char) -> *mut c
|
||||
|
||||
let resp: String;
|
||||
{
|
||||
let lc = LIGHTCLIENT.lock().unwrap();
|
||||
let lightclient: Arc<LightClient>;
|
||||
{
|
||||
let lc = LIGHTCLIENT.lock().unwrap();
|
||||
|
||||
if lc.borrow().is_none() {
|
||||
let e_str = CString::new("Error: Light Client is not initialized").unwrap();
|
||||
return e_str.into_raw();
|
||||
}
|
||||
if lc.borrow().is_none() {
|
||||
let e_str = CString::new("Error: Light Client is not initialized").unwrap();
|
||||
return e_str.into_raw();
|
||||
}
|
||||
|
||||
lightclient = lc.borrow().as_ref().unwrap().clone();
|
||||
};
|
||||
|
||||
let args = if arg_str.is_empty() { vec![] } else { vec![arg_str.as_ref()] };
|
||||
|
||||
resp = commands::do_user_command(&cmd_str, &args, lc.borrow().as_ref().unwrap()).clone();
|
||||
resp = commands::do_user_command(&cmd_str, &args, lightclient.as_ref()).clone();
|
||||
};
|
||||
|
||||
let c_str = CString::new(resp.as_bytes()).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user