Skip to content

Commit b0c2fd4

Browse files
Use BTreeSet/BTreeMap instead of HashSet/HashMap
1 parent b393f25 commit b0c2fd4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/plan.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ impl Plan {
460460
}
461461
}
462462

463-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
463+
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
464464
/// Signatures which a key can produce
465465
///
466466
/// Defaults to `ecdsa=true` and `taproot=TaprootCanSign::default()`
@@ -480,7 +480,7 @@ impl Default for CanSign {
480480
}
481481
}
482482

483-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
483+
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
484484
/// Signatures which a taproot key can produce
485485
///
486486
/// Defaults to `key_spend=true`, `script_spend=Any` and `sighash_default=true`
@@ -512,7 +512,7 @@ impl Default for TaprootCanSign {
512512
}
513513
}
514514

515-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
515+
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
516516
/// Which taproot leaves the key can sign for
517517
pub enum TaprootAvailableLeaves {
518518
/// Cannot sign for any leaf
@@ -546,15 +546,15 @@ pub struct Assets {
546546
/// derived with either `derivation_path` or a derivation path that extends `derivation_path`
547547
/// by exactly one child number. For example, if the derivation path `m/0/1` is provided, the
548548
/// user can sign with either `m/0/1` or `m/0/1/*`.
549-
pub keys: HashSet<(bip32::KeySource, CanSign)>,
549+
pub keys: BTreeSet<(bip32::KeySource, CanSign)>,
550550
/// Set of available sha256 preimages
551-
pub sha256_preimages: HashSet<sha256::Hash>,
551+
pub sha256_preimages: BTreeSet<sha256::Hash>,
552552
/// Set of available hash256 preimages
553-
pub hash256_preimages: HashSet<hash256::Hash>,
553+
pub hash256_preimages: BTreeSet<hash256::Hash>,
554554
/// Set of available ripemd160 preimages
555-
pub ripemd160_preimages: HashSet<ripemd160::Hash>,
555+
pub ripemd160_preimages: BTreeSet<ripemd160::Hash>,
556556
/// Set of available hash160 preimages
557-
pub hash160_preimages: HashSet<hash160::Hash>,
557+
pub hash160_preimages: BTreeSet<hash160::Hash>,
558558
/// Maximum absolute timelock allowed
559559
pub absolute_timelock: Option<LockTime>,
560560
/// Maximum relative timelock allowed
@@ -679,7 +679,7 @@ impl AssetProvider<DefiniteDescriptorKey> for Assets {
679679

680680
impl FromIterator<DescriptorPublicKey> for Assets {
681681
fn from_iter<I: IntoIterator<Item = DescriptorPublicKey>>(iter: I) -> Self {
682-
let mut keys = HashSet::new();
682+
let mut keys = BTreeSet::new();
683683
for pk in iter {
684684
for deriv_path in pk.full_derivation_paths() {
685685
keys.insert(((pk.master_fingerprint(), deriv_path), CanSign::default()));
@@ -699,8 +699,8 @@ pub trait IntoAssets {
699699
}
700700

701701
impl IntoAssets for KeyMap {
702-
fn into_assets(mut self) -> Assets {
703-
Assets::from_iter(self.drain().map(|(k, _)| k))
702+
fn into_assets(self) -> Assets {
703+
Assets::from_iter(self.into_iter().map(|(k, _)| k))
704704
}
705705
}
706706

0 commit comments

Comments
 (0)