Skip to content

Commit

Permalink
Merge pull request #3 from functionland/corrected_put_get
Browse files Browse the repository at this point in the history
Update lib.rs
  • Loading branch information
hhio618 authored Dec 1, 2022
2 parents b57190f + 11f0733 commit 9539b21
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions wnfslib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub mod android {
let get_fn = self.env
.get_method_id(
self.fula_client,
"get",
"get_block",
"([B;)[B;",
)
.unwrap();
Expand All @@ -68,31 +68,33 @@ pub mod android {
}

/// Stores an array of bytes in the block store.
fn put_block(&self, cid: Vec<u8>, bytes: Vec<u8>) -> Result<Vec<u8>>{
fn put_block(&self, bytes: Vec<u8>, codec: Vec<u8>) -> Result<Vec<u8>>{
let put_fn = self.env
.get_method_id(
self.fula_client,
"put",
"([B;[B;);",
"put_block",
"([B;[B;)[B;",
)
.unwrap();

let cidJByteArray = vec_to_jbyteArray(self.env, cid.to_owned());
let codecJByteArray = vec_to_jbyteArray(self.env, codec.to_owned());
let dataJByteArray = vec_to_jbyteArray(self.env, bytes);
self.env
let cidJByteArray = self.env
.call_method_unchecked(
self.fula_client,
put_fn,
JavaType::Object(String::from("")),
JavaType::Object(String::from("[B")),
&[
JValue::from(cidJByteArray),
JValue::from(codecJByteArray),
JValue::from(dataJByteArray),
],
)
.unwrap()
.l()
.unwrap();
Ok(cid.to_owned())

let cid = jbyteArray_to_vec(self.env, cidJByteArray.into_inner());
Ok(cid)
}
}

Expand Down

0 comments on commit 9539b21

Please sign in to comment.