Skip to content

Commit d097867

Browse files
Use BTreeSet/BTreeMap instead of HashSet/HashMap
1 parent 53a7284 commit d097867

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
@@ -461,7 +461,7 @@ impl Plan {
461461
}
462462
}
463463

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

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

516-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
516+
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
517517
/// Which taproot leaves the key can sign for
518518
pub enum TaprootAvailableLeaves {
519519
/// Cannot sign for any leaf
@@ -547,15 +547,15 @@ pub struct Assets {
547547
/// derived with either `derivation_path` or a derivation path that extends `derivation_path`
548548
/// by exactly one child number. For example, if the derivation path `m/0/1` is provided, the
549549
/// user can sign with either `m/0/1` or `m/0/1/*`.
550-
pub keys: HashSet<(bip32::KeySource, CanSign)>,
550+
pub keys: BTreeSet<(bip32::KeySource, CanSign)>,
551551
/// Set of available sha256 preimages
552-
pub sha256_preimages: HashSet<sha256::Hash>,
552+
pub sha256_preimages: BTreeSet<sha256::Hash>,
553553
/// Set of available hash256 preimages
554-
pub hash256_preimages: HashSet<hash256::Hash>,
554+
pub hash256_preimages: BTreeSet<hash256::Hash>,
555555
/// Set of available ripemd160 preimages
556-
pub ripemd160_preimages: HashSet<ripemd160::Hash>,
556+
pub ripemd160_preimages: BTreeSet<ripemd160::Hash>,
557557
/// Set of available hash160 preimages
558-
pub hash160_preimages: HashSet<hash160::Hash>,
558+
pub hash160_preimages: BTreeSet<hash160::Hash>,
559559
/// Maximum absolute timelock allowed
560560
pub absolute_timelock: Option<LockTime>,
561561
/// Maximum relative timelock allowed
@@ -680,7 +680,7 @@ impl AssetProvider<DefiniteDescriptorKey> for Assets {
680680

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

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

0 commit comments

Comments
 (0)