-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CommitmentTree interface updated. #74
Conversation
api/src/lib.rs
Outdated
_sc_id: jbyteArray | ||
) -> jobject | ||
{ | ||
let sc_id = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these cases you can use the "deserialize_to_jobject" function to save a little bit of code lines and duplication. But don't bother, we will highly refactor the library anyway
let field_class = _env.find_class("com/horizen/librustsidechains/FieldElement") | ||
.expect("Should be able to find FieldElement class"); | ||
|
||
let initial_element = _env.new_object(field_class, "(J)V", &[ | ||
JValue::Long(0)]).expect("Should be able to create new long for FieldElement"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these cases, you can use the "return_jobject" function to save a little bit of code lines and duplication. But don't bother, we will highly refactor the library anyway
let cls_optional = _env.find_class("java/util/Optional").unwrap(); | ||
|
||
let empty_res = _env.call_static_method(cls_optional, "of", "(Ljava/lang/Object;)Ljava/util/Optional;", &[JValue::from(JObject::from(leaf_fe_array))]) | ||
.expect("Should be able to create new value for Optional"); | ||
|
||
*empty_res.l().unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not important, to save a little bit of code we might consider writing and using a generic function that wraps a JObject into another Optional JObject (or maybe directly into a jobject to return it immediately)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I completely agree with you. In these methods there is a lot of boilerplate that should be moved to common utility methods.
Currently, just reused the same approach as we have in other places.
09afce0
to
fd6134f
Compare
No description provided.