romanz / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
1.09k stars 402 forks source link

Feature: shared RPC types #848

Open Kixunil opened 1 year ago

Kixunil commented 1 year ago

Is your feature request related to a problem? Please describe. Looking at the electrum client crates, I'm a bit dissatisfied. The maintained one is sync-only, there's another unmaintained, undocumented one using async and hyper (WTF?! electrum doesn't use HTTP!). I'm considering forking/making my own with this hierarchy of crates:

This improves code reuse. Postgres crates are organized similarly.

I'm wondering if it'd make sense to also share the types with electrs to improve reuse even more.

(Tangentially, I'm considering doing the same with bitcoincore-rpc because it's unmaintained.)

Describe the solution you'd like Cut out the RPC types from electrs to a separate crate that electrs will depend on and double check with the other crates to make sure they are usable on both sides. We could also have a rust-electrum organization to keep everything in one place.

Describe alternatives you've considered The only other solution I see is just not working together which may be a bunch of work.

romanz commented 1 year ago

Describe the solution you'd like Cut out the RPC types from electrs to a separate crate that electrs will depend on and double check with the other crates to make sure they are usable on both sides. We could also have a rust-electrum organization to keep everything in one place.

Sounds great :)

Kixunil commented 1 year ago

One thing I realized is that while receivers would prefer String or Cow<'de, str>, senders might prefer &str for performance. I guess Cow is a sweet spot but maybe the types should be generic over storage instead?

cryptoquick commented 1 year ago

This will also help a lot with #820. If separate crates are desired, do either of you think it would make sense to make electrs a Cargo workspace, so all these contributions can be put in one place? And if so, would you also be open to accepting a PR for a crate, electrum-http-proxy ?

Kixunil commented 1 year ago

This seems to be completely unrelated to #820 unless the HTTP API uses the same protocol just over HTTP instead of one line per request, in which case the types could be reused if they are specified to be the same. Note however that I don't see how notifications can be handled. Those need to be asynchronous, so probably requires websocket or http 2 or something.