add hex as required dependency, then use it inside init_blocks_table

This commit is contained in:
Kevin Gorham 2019-02-22 09:52:03 -05:00
parent 2c4a48b772
commit 245841807c
4 changed files with 9 additions and 7 deletions

View File

@ -14,7 +14,7 @@ android_logger = "0.6"
failure = "0.1"
futures = { version = "0.1", optional = true }
grpc = { version = "0.6", optional = true }
hex = { version = "0.3", optional = true }
hex = "0.3"
jni = { version = "0.10", default-features = false }
log = "0.4"
log-panics = "2.0.0"
@ -52,7 +52,7 @@ dirs = "1"
tempfile = "3"
[features]
updater = ["futures", "grpc", "hex"]
updater = ["futures", "grpc"]
[lib]
name = "zcashwalletsdk"

View File

@ -13,7 +13,7 @@ class JniConverter {
dbData: String,
height: Int,
time: Long,
saplingTree: ByteArray): Boolean
saplingTree: String): Boolean
external fun getAddress(dbData: String, account: Int): String

View File

@ -26,11 +26,11 @@ const BATCH_SIZE: u64 = 10_000;
fn print_sapling_tree(height: u64, time: u32, tree: CommitmentTree) {
let mut tree_bytes = vec![];
tree.write(&mut tree_bytes).unwrap();
println!("{");
println!("{{");
println!(" \"height\": {},", height);
println!(" \"time\": {},", time);
println!(" \"tree\": \"{}\",", hex::encode(tree_bytes));
println!("}");
println!("}}");
}
fn main() {

View File

@ -1,5 +1,6 @@
#[macro_use]
extern crate log;
extern crate hex;
mod sql;
mod utils;
@ -119,7 +120,7 @@ pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_initBlocksTable
db_data: JString<'_>,
height: jint,
time: jlong,
sapling_tree: jbyteArray,
sapling_tree_string: JString<'_>,
) -> jboolean {
let res = panic::catch_unwind(|| {
let db_data = utils::java_string_to_rust(&env, db_data);
@ -128,7 +129,8 @@ pub unsafe extern "C" fn Java_cash_z_wallet_sdk_jni_JniConverter_initBlocksTable
} else {
return Err(format_err!("time argument must fit in a u32"));
};
let sapling_tree = env.convert_byte_array(sapling_tree).unwrap();
let sapling_tree =
hex::decode(utils::java_string_to_rust(&env, sapling_tree_string)).unwrap();
match init_blocks_table(&db_data, height, time, &sapling_tree) {
Ok(()) => Ok(JNI_TRUE),