keyforkd: clone internal Arc instead of external struct holding Arc
This commit is contained in:
parent
88dd6476df
commit
c39d8343c7
|
@ -4,6 +4,9 @@ use keyfork_derive_util::request::{DerivationError, DerivationRequest, Derivatio
|
||||||
use keyfork_mnemonic_util::Mnemonic;
|
use keyfork_mnemonic_util::Mnemonic;
|
||||||
use tower::Service;
|
use tower::Service;
|
||||||
|
|
||||||
|
// NOTE: All values implemented in Keyforkd must implement Clone with low overhead, either by
|
||||||
|
// using an Arc or by having a small signature. This is because Service<T> takes &mut self.
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Keyforkd {
|
pub struct Keyforkd {
|
||||||
mnemonic: Arc<Mnemonic>,
|
mnemonic: Arc<Mnemonic>,
|
||||||
|
@ -33,7 +36,7 @@ impl Service<DerivationRequest> for Keyforkd {
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))]
|
||||||
fn call(&mut self, req: DerivationRequest) -> Self::Future {
|
fn call(&mut self, req: DerivationRequest) -> Self::Future {
|
||||||
let app = self.clone();
|
let mnemonic = self.mnemonic.clone();
|
||||||
Box::pin(async { req.derive_with_mnemonic(&app.mnemonic) })
|
Box::pin(async { req.derive_with_mnemonic(&mnemonic) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue