-
Notifications
You must be signed in to change notification settings - Fork 1.7k
parity-clib: async C bindings to RPC requests
+ subscribe/unsubscribe to websocket events
#9920
Conversation
3bae6fb
to
86ff729
Compare
async C bindings to RPC queries
async C bindings to RPC queries
5f7f1ae
to
350b13a
Compare
async C bindings to RPC queries
async C bindings to RPC query
+ subscribe/unsubscribe to websocket events
async C bindings to RPC query
+ subscribe/unsubscribe to websocket events
async C bindings to RPC requests
+ subscribe/unsubscribe to websocket events
The PR should be in The easiest way if you want to test it, grab the update cpp example and then make sure that you are fully-synced otherwise |
3e4c677
to
c1a8cc9
Compare
b897ac4
to
55a0d2e
Compare
I have started to look at the Java bindings and the synchronous part works fine. However, the asynchronous part is a different story in order to invoke a java method I have to do by using the JNI/JVM environment AFAIU Something like env.call_method(
callback,
"callback",
"(JLjava/lang/Object;Ljava/lang/Object;J)V",
&[JValue::Long(0), JValue::Object(null), JValue::Object(null), JValue::Long(0)]
).expect("Java method call failed"); Thus, using the
Thoughts? |
impl CallbackStr { | ||
fn call(&self, msg: &[u8]) { | ||
if let Some(ref cb) = self.f { | ||
let cstr = CString::new(msg).expect("valid string with no null bytes in the middle; qed").into_raw(); |
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.
This may be a performance bottleneck, it is O(n) + additional allocation but nice to have from a C/C++ perspective
but for other languages such as Java, I expect that it still requires to copy these raw bytes
into respective String type!
98b3f18
to
8968c16
Compare
* Subscribing to websockets for the full-client works
* Enforce C+11
* Use it the example to avoid using global variables
Forgot to pass the JNIEnv environment since it is an instance method
* Remove Java dependency by constructing a valid Java String in the callback
* `cpp` example pass in a struct instead to determines `callback kind` * `java` add a instance variable the class `Callback` to determine `callback kind`
Co-Authored-By: niklasad1 <niklasadolfsson1@gmail.com>
e4be3e4
to
48d5706
Compare
48d5706
to
a50b062
Compare
@5chdn The parity-clib/example was moved so the source path didn't work. I will fix this soon |
* fix(remove needless unsafe blocks) * style(nits) * fix(parity-clib): eliminate repetitive event loops * revert(java bindings): safe rust -> unsafe rust These functions can still end up with `UB` thus should be unsafe * fix(grumbles): make Callback trait `pub (crate)`
* master: no volumes are needed, just run -v volume:/path/in/the/container (#10345) Fixed misstype (#10351) snap: prefix version and populate candidate channel (#10343) Bundle protocol and packet_id together in chain sync (#10315) role back docker build image and docker deploy image to ubuntu:xenial based (#10338) change docker image based on debian instead of ubuntu due to the chan… (#10336) Don't add discovery initiators to the node table (#10305) fix(docker): fix not receives SIGINT (#10059) snap: official image / test (#10168) fix(add helper for timestamp overflows) (#10330) Additional error for invalid gas (#10327) Revive parity_setMinGasPrice RPC call (#10294) Add Statetest support for Constantinople Fix (#10323) fix(parity-clib): grumbles that were not addressed in #9920 (#10154) fix(light-rpc): Make `light_sync` generic (#10238) fix publish job (#10317) Secure WS-RPC: grant access to all apis (#10246) Make specification of protocol in SyncRequester::send_request explicit (#10295)
Attempt to close #9271
This PR changes to following in parity-clib (C and Java bindings):
Additional changes:
party-cpp-example
TODOs:
Pitfalls/suggested improvements, should be fixed in this PR?!
finalize()
in Parity.Java (I have looked into it very briefly and the way to go is to use PhantomReference instead but requires more boilerplate code and I like currently how simple the Parity class is)