Skip to content

Commit

Permalink
zcash_client_backend: Add tor::Client::isolated_client
Browse files Browse the repository at this point in the history
This enables a single Tor client to create independent connections to
multiple `lightwalletd` instances (or the same instance several times).
  • Loading branch information
str4d committed Jul 29, 2024
1 parent 6449e5c commit 68b883d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions zcash_client_backend/src/tor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ impl Client {

Ok(Self { inner })
}

/// Returns a new isolated `tor::Client` handle.
///
/// The two `tor::Client`s will share internal state and configuration, but their
/// streams will never share circuits with one another.
///
/// Use this method when you want separate parts of your program to each have a
/// `tor::Client` handle, but where you don't want their activities to be linkable to
/// one another over the Tor network.
///
/// Calling this method is usually preferable to creating a completely separate
/// `tor::Client` instance, since it can share its internals with the existing
/// `tor::Client`.
///
/// (Connections made with clones of the returned `tor::Client` may share circuits
/// with each other.)
#[must_use]
pub fn isolated_client(&self) -> Self {
Self {
inner: self.inner.isolated_client(),
}
}
}

/// Errors that can occur while creating or using a Tor [`Client`].
Expand Down

0 comments on commit 68b883d

Please # to comment.