Skip to content

Commit eecd2cd

Browse files
committed
Drop lightning-invoice dependency on hashbrown`
1 parent 3096061 commit eecd2cd

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

lightning-invoice/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ rustdoc-args = ["--cfg", "docsrs"]
1616

1717
[features]
1818
default = ["std"]
19-
no-std = ["hashbrown", "lightning/no-std"]
19+
no-std = ["lightning/no-std"]
2020
std = ["bitcoin/std", "num-traits/std", "lightning/std", "bech32/std"]
2121

2222
[dependencies]
2323
bech32 = { version = "0.9.0", default-features = false }
2424
lightning = { version = "0.0.121", path = "../lightning", default-features = false }
2525
secp256k1 = { version = "0.27.0", default-features = false, features = ["recovery", "alloc"] }
2626
num-traits = { version = "0.2.8", default-features = false }
27-
hashbrown = { version = "0.13", optional = true }
2827
serde = { version = "1.0.118", optional = true }
2928
bitcoin = { version = "0.30.2", default-features = false }
3029

3130
[dev-dependencies]
3231
lightning = { version = "0.0.121", path = "../lightning", default-features = false, features = ["_test_utils"] }
3332
hex = { package = "hex-conservative", version = "0.1.1", default-features = false }
3433
serde_json = { version = "1"}
34+
hashbrown = { version = "0.13", default-features = false }

lightning-invoice/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,7 @@ mod tb;
7979

8080
#[allow(unused_imports)]
8181
mod prelude {
82-
#[cfg(feature = "hashbrown")]
83-
extern crate hashbrown;
84-
8582
pub use alloc::{vec, vec::Vec, string::String};
86-
#[cfg(not(feature = "hashbrown"))]
87-
pub use std::collections::{HashMap, hash_map};
88-
#[cfg(feature = "hashbrown")]
89-
pub use self::hashbrown::{HashMap, HashSet, hash_map};
9083

9184
pub use alloc::string::ToString;
9285
}

lightning-invoice/src/utils.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use lightning::routing::gossip::RoutingFees;
1616
use lightning::routing::router::{RouteHint, RouteHintHop, Router};
1717
use lightning::util::logger::{Logger, Record};
1818
use secp256k1::PublicKey;
19+
use alloc::collections::{btree_map, BTreeMap};
1920
use core::ops::Deref;
2021
use core::time::Duration;
2122
use core::iter::Iterator;
@@ -603,7 +604,7 @@ fn sort_and_filter_channels<L: Deref>(
603604
where
604605
L::Target: Logger,
605606
{
606-
let mut filtered_channels: HashMap<PublicKey, ChannelDetails> = HashMap::new();
607+
let mut filtered_channels: BTreeMap<PublicKey, ChannelDetails> = BTreeMap::new();
607608
let min_inbound_capacity = min_inbound_capacity_msat.unwrap_or(0);
608609
let mut min_capacity_channel_exists = false;
609610
let mut online_channel_exists = false;
@@ -664,7 +665,7 @@ where
664665
}
665666

666667
match filtered_channels.entry(channel.counterparty.node_id) {
667-
hash_map::Entry::Occupied(mut entry) => {
668+
btree_map::Entry::Occupied(mut entry) => {
668669
let current_max_capacity = entry.get().inbound_capacity_msat;
669670
// If this channel is public and the previous channel is not, ensure we replace the
670671
// previous channel to avoid announcing non-public channels.
@@ -697,7 +698,7 @@ where
697698
channel.inbound_capacity_msat);
698699
}
699700
}
700-
hash_map::Entry::Vacant(entry) => {
701+
btree_map::Entry::Vacant(entry) => {
701702
entry.insert(channel);
702703
}
703704
}

0 commit comments

Comments
 (0)