Convenience API (or example) for a lazy-init TorClient
On https://forum.zcashcommunity.com/t/arti-a-pure-rust-tor-implementation-for-zcash-and-beyond/38776/55 , teor says:
There are a few missing APIs that would help make our code more efficient, and might reduce our load on the Tor network:
An API that bootstraps Tor if needed, then returns a cloned Tor client
Making a shared
TorClient
instance was a bit tricky, because it’s hard to lazily call async code in Rust, and then share the result. So I ended up wrapping the shared value in anArc<Mutex<_>>
. But this seems like a bit of a waste, because there’s already a lot of locking insideTorClient
.Here are some API changes that might have made that easier:
- an API or example code that initializes a shared
TorClient
when it is first used, then clones the shared instance for future requests- a non-async API that configures and allocates a shared
TorClient
, then bootstraps it when it actually gets its first request (or when an async bootstrap method gets called)- if possible, making arti_client::Error cloneable, so arti futures be used with FutureExt::shared
The error issue falls under #247 (closed); the other issues seem like something we should provide.