Skip to content
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

Async version of bitcoincore-rpc #78

Open
thomaseizinger opened this issue Sep 25, 2019 · 10 comments
Open

Async version of bitcoincore-rpc #78

thomaseizinger opened this issue Sep 25, 2019 · 10 comments

Comments

@thomaseizinger
Copy link
Contributor

Is there an async version of the library in the planning?

I guess that is blocked by async support in jsonrpc?

@stevenroose
Copy link
Collaborator

Is there demand for an async version?

@stevenroose
Copy link
Collaborator

stevenroose commented Sep 25, 2019

I think if we do this, I would like to do it in a way that also supports batching. Like every call returns an object that can have several getters, one for an async execution, a sync execution or being added to a batch.

@thomaseizinger
Copy link
Contributor Author

Is there demand for an async version?

We would need it 😬
It is kind of painful to use a blocking library in a totally async system. The only thing I can think of to do it properly is to have a dedicated execution thread that you communicate with via channels.

Apart from that, most of the Rust ecosystem around networking is already async (tokio, async-std). In addition, async/await is landing on stable for the next release (1.39).

jsonrpc is based on hyper, so it should be fairly trivial to adapt to an async interface. There is also reqwest, a very popular http client library that supports Futures or surf.

@thomaseizinger
Copy link
Contributor Author

I think if we do this, I would like to do it in a way that also supports batching.

Batching as in, sending the requests at once and wait for all their results?
You can join together several futures and then spawn them all at the same time. However, it will still result in several HTTP calls but that is due to the way JsonRPC works and I think you can't get around that.

@chris-belcher
Copy link

Is there demand for an async version?

If you're still measuring demand then I need to signal that I would also like an async version.

The async paradigm is really good because it keeps the app responsive and resource-efficent, without damaging the code's readability as with what happens with a select() loop

@sgeisler
Copy link
Contributor

At some point I'll need some form of async support too for a project I'm working on and might just build it then.

@TheBlueMatt
Copy link
Member

There's definitely some demand. We have a RPC/REST client that can act as a trivial SPV client at https://github.com/rust-bitcoin/rust-lightning/pull/614/files#diff-386a00d0abcf87d8b4cff018609f2b56 that is all async.

@JeremyRubin
Copy link

FWIW I put together a set of crates based on the rust-bitcoin suite that use async:

https://crates.io/crates/bitcoincore-rpc-async
https://crates.io/crates/bitcoincore-rpc-json-async
https://crates.io/crates/jsonrpc-async

Not heavily tested, but the changes weren't too intense.

@stevenroose
Copy link
Collaborator

Please give some feedback on this idea I have, it might be relevant to this discussion: #212

@gd87429
Copy link

gd87429 commented Nov 14, 2022

If you're still measuring demand then I need to signal that I would also like an async version.

Same here. Wish this had async support. It's been 3 years since this issue was opened, and I think async is a lot more popular/common in Rust now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants