Skip to content

Commit dfd7f1f

Browse files
committed
Remove hashbrown dependency
Replace the usage of `HashMap` and `HashSet` with `BTreeMap` and `BTreeSet` and remove the `hashbrown` dependency This is an API breaking change because the `KeyMap` type is public.
1 parent 34fea60 commit dfd7f1f

File tree

5 files changed

+6
-13
lines changed

5 files changed

+6
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition = "2018"
1313
[features]
1414
default = ["std"]
1515
std = ["bitcoin/std", "bitcoin/secp-recovery"]
16-
no-std = ["hashbrown", "bitcoin/no-std"]
16+
no-std = ["bitcoin/no-std"]
1717
compiler = []
1818
trace = []
1919

@@ -24,7 +24,6 @@ base64 = ["bitcoin/base64"]
2424

2525
[dependencies]
2626
bitcoin = { version = "0.30.0", default-features = false }
27-
hashbrown = { version = "0.11", optional = true }
2827
internals = { package = "bitcoin-private", version = "0.1.0", default_features = false }
2928

3029
# Do NOT use this as a feature! Use the `serde` feature instead.

src/descriptor/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub use self::key::{
5757
/// [`Descriptor::parse_descriptor`], since the descriptor will always only contain
5858
/// public keys. This map allows looking up the corresponding secret key given a
5959
/// public key from the descriptor.
60-
pub type KeyMap = HashMap<DescriptorPublicKey, DescriptorSecretKey>;
60+
pub type KeyMap = BTreeMap<DescriptorPublicKey, DescriptorSecretKey>;
6161

6262
/// Script descriptor
6363
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -658,7 +658,7 @@ impl Descriptor<DescriptorPublicKey> {
658658
Ok(public_key)
659659
}
660660

661-
let mut keymap_pk = KeyMapWrapper(HashMap::new(), secp);
661+
let mut keymap_pk = KeyMapWrapper(BTreeMap::new(), secp);
662662

663663
struct KeyMapWrapper<'a, C: secp256k1::Signing>(KeyMap, &'a secp256k1::Secp256k1<C>);
664664

@@ -1503,7 +1503,7 @@ mod tests {
15031503
witness: Witness::default(),
15041504
};
15051505
let satisfier = {
1506-
let mut satisfier = HashMap::with_capacity(2);
1506+
let mut satisfier = BTreeMap::new();
15071507

15081508
satisfier.insert(
15091509
a,

src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ pub use bitcoin;
9999
#[macro_use]
100100
extern crate alloc;
101101

102-
#[cfg(not(feature = "std"))]
103-
extern crate hashbrown;
104-
105102
#[cfg(any(feature = "std", test))]
106103
extern crate core;
107104

@@ -973,9 +970,6 @@ mod prelude {
973970
vec::Vec,
974971
};
975972

976-
#[cfg(all(not(feature = "std"), not(test)))]
977-
pub use hashbrown::{HashMap, HashSet};
978-
979973
#[cfg(all(not(feature = "std"), not(test)))]
980974
pub use self::mutex::Mutex;
981975
}

src/miniscript/analyzable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
214214
// to have an iterator
215215
let all_pkhs_len = self.iter_pk().count();
216216

217-
let unique_pkhs_len = self.iter_pk().collect::<HashSet<_>>().len();
217+
let unique_pkhs_len = self.iter_pk().collect::<BTreeSet<_>>().len();
218218

219219
unique_pkhs_len != all_pkhs_len
220220
}

src/policy/concrete.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
792792
pub fn check_duplicate_keys(&self) -> Result<(), PolicyError> {
793793
let pks = self.keys();
794794
let pks_len = pks.len();
795-
let unique_pks_len = pks.into_iter().collect::<HashSet<_>>().len();
795+
let unique_pks_len = pks.into_iter().collect::<BTreeSet<_>>().len();
796796

797797
if pks_len > unique_pks_len {
798798
Err(PolicyError::DuplicatePubKeys)

0 commit comments

Comments
 (0)