Remove redundant Box around signers
This commit is contained in:
parent
5784a95e48
commit
3b3659fc0c
@ -205,7 +205,7 @@ where
|
|||||||
script_type: ScriptType,
|
script_type: ScriptType,
|
||||||
id: SignerId,
|
id: SignerId,
|
||||||
ordering: SignerOrdering,
|
ordering: SignerOrdering,
|
||||||
signer: Arc<Box<dyn Signer>>,
|
signer: Arc<dyn Signer>,
|
||||||
) {
|
) {
|
||||||
let signers = match script_type {
|
let signers = match script_type {
|
||||||
ScriptType::External => Arc::make_mut(&mut self.signers),
|
ScriptType::External => Arc::make_mut(&mut self.signers),
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
//! ScriptType::External,
|
//! ScriptType::External,
|
||||||
//! Fingerprint::from_str("e30f11b8").unwrap().into(),
|
//! Fingerprint::from_str("e30f11b8").unwrap().into(),
|
||||||
//! SignerOrdering(200),
|
//! SignerOrdering(200),
|
||||||
//! Arc::new(Box::new(custom_signer))
|
//! Arc::new(custom_signer)
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
//! # Ok::<_, bdk::Error>(())
|
//! # Ok::<_, bdk::Error>(())
|
||||||
@ -320,7 +320,7 @@ impl From<(SignerId, SignerOrdering)> for SignersContainerKey {
|
|||||||
|
|
||||||
/// Container for multiple signers
|
/// Container for multiple signers
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct SignersContainer(BTreeMap<SignersContainerKey, Arc<Box<dyn Signer>>>);
|
pub struct SignersContainer(BTreeMap<SignersContainerKey, Arc<dyn Signer>>);
|
||||||
|
|
||||||
impl SignersContainer {
|
impl SignersContainer {
|
||||||
pub fn as_key_map(&self) -> KeyMap {
|
pub fn as_key_map(&self) -> KeyMap {
|
||||||
@ -346,12 +346,12 @@ impl From<KeyMap> for SignersContainer {
|
|||||||
.to_pubkeyhash(),
|
.to_pubkeyhash(),
|
||||||
),
|
),
|
||||||
SignerOrdering::default(),
|
SignerOrdering::default(),
|
||||||
Arc::new(Box::new(private_key.key)),
|
Arc::new(private_key.key),
|
||||||
),
|
),
|
||||||
DescriptorSecretKey::XPrv(xprv) => container.add_external(
|
DescriptorSecretKey::XPrv(xprv) => container.add_external(
|
||||||
SignerId::from(xprv.root_fingerprint()),
|
SignerId::from(xprv.root_fingerprint()),
|
||||||
SignerOrdering::default(),
|
SignerOrdering::default(),
|
||||||
Arc::new(Box::new(xprv)),
|
Arc::new(xprv),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -372,17 +372,13 @@ impl SignersContainer {
|
|||||||
&mut self,
|
&mut self,
|
||||||
id: SignerId,
|
id: SignerId,
|
||||||
ordering: SignerOrdering,
|
ordering: SignerOrdering,
|
||||||
signer: Arc<Box<dyn Signer>>,
|
signer: Arc<dyn Signer>,
|
||||||
) -> Option<Arc<Box<dyn Signer>>> {
|
) -> Option<Arc<dyn Signer>> {
|
||||||
self.0.insert((id, ordering).into(), signer)
|
self.0.insert((id, ordering).into(), signer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes a signer from the container and returns it
|
/// Removes a signer from the container and returns it
|
||||||
pub fn remove(
|
pub fn remove(&mut self, id: SignerId, ordering: SignerOrdering) -> Option<Arc<dyn Signer>> {
|
||||||
&mut self,
|
|
||||||
id: SignerId,
|
|
||||||
ordering: SignerOrdering,
|
|
||||||
) -> Option<Arc<Box<dyn Signer>>> {
|
|
||||||
self.0.remove(&(id, ordering).into())
|
self.0.remove(&(id, ordering).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,12 +391,12 @@ impl SignersContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the list of signers in the container, sorted by lowest to highest `ordering`
|
/// Returns the list of signers in the container, sorted by lowest to highest `ordering`
|
||||||
pub fn signers(&self) -> Vec<&Arc<Box<dyn Signer>>> {
|
pub fn signers(&self) -> Vec<&Arc<dyn Signer>> {
|
||||||
self.0.values().collect()
|
self.0.values().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds the signer with lowest ordering for a given id in the container.
|
/// Finds the signer with lowest ordering for a given id in the container.
|
||||||
pub fn find(&self, id: SignerId) -> Option<&Arc<Box<dyn Signer>>> {
|
pub fn find(&self, id: SignerId) -> Option<&Arc<dyn Signer>> {
|
||||||
self.0
|
self.0
|
||||||
.range((
|
.range((
|
||||||
Included(&(id.clone(), SignerOrdering(0)).into()),
|
Included(&(id.clone(), SignerOrdering(0)).into()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user