Skip to content

Commit 64c9916

Browse files
committed
Do not rely on auto-deref'ing when aaccessing a Hash{Map,Set}
In newer versions of `hashbrown` this code would be broken. While we aren't updating `hashbrown` any time soon (as it requires an MSRV bump), it is useful to swap for a newer `hashbrown` when fuzzing, which this makes easier.
1 parent ffc3b13 commit 64c9916

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lightning/src/chain/onchaintx.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
475475
// remove it once it reaches the confirmation threshold, or to generate a new claim if the
476476
// transaction is reorged out.
477477
let mut all_inputs_have_confirmed_spend = true;
478-
for outpoint in &request_outpoints {
479-
if let Some(first_claim_txid_height) = self.claimable_outpoints.get(outpoint) {
478+
for outpoint in request_outpoints.iter() {
479+
if let Some(first_claim_txid_height) = self.claimable_outpoints.get(*outpoint) {
480480
// We check for outpoint spends within claims individually rather than as a set
481481
// since requests can have outpoints split off.
482482
if !self.onchain_events_awaiting_threshold_conf.iter()
@@ -810,7 +810,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
810810
for outpoint in request.outpoints() {
811811
log_debug!(logger, "Removing claim tracking for {} due to maturation of claim package {}.",
812812
outpoint, log_bytes!(package_id));
813-
self.claimable_outpoints.remove(&outpoint);
813+
self.claimable_outpoints.remove(outpoint);
814814
#[cfg(anchors)]
815815
self.pending_claim_events.remove(&package_id);
816816
}
@@ -819,7 +819,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
819819
OnchainEvent::ContentiousOutpoint { package } => {
820820
log_debug!(logger, "Removing claim tracking due to maturation of claim tx for outpoints:");
821821
log_debug!(logger, " {:?}", package.outpoints());
822-
self.claimable_outpoints.remove(&package.outpoints()[0]);
822+
self.claimable_outpoints.remove(package.outpoints()[0]);
823823
}
824824
}
825825
} else {
@@ -897,7 +897,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
897897
//- resurect outpoint back in its claimable set and regenerate tx
898898
match entry.event {
899899
OnchainEvent::ContentiousOutpoint { package } => {
900-
if let Some(ancestor_claimable_txid) = self.claimable_outpoints.get(&package.outpoints()[0]) {
900+
if let Some(ancestor_claimable_txid) = self.claimable_outpoints.get(package.outpoints()[0]) {
901901
if let Some(request) = self.pending_claim_requests.get_mut(&ancestor_claimable_txid.0) {
902902
request.merge_package(package);
903903
// Using a HashMap guarantee us than if we have multiple outpoints getting

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ where
16601660
}
16611661
let (shutdown_msg, monitor_update, htlcs) = {
16621662
let per_peer_state = self.per_peer_state.read().unwrap();
1663-
match per_peer_state.get(&counterparty_node_id) {
1663+
match per_peer_state.get(counterparty_node_id) {
16641664
Some(peer_state) => {
16651665
let peer_state = peer_state.lock().unwrap();
16661666
let their_features = &peer_state.latest_features;
@@ -2060,7 +2060,7 @@ where
20602060
// short_channel_id is non-0 in any ::Forward.
20612061
if let &PendingHTLCRouting::Forward { ref short_channel_id, .. } = routing {
20622062
if let Some((err, mut code, chan_update)) = loop {
2063-
let id_option = self.short_to_chan_info.read().unwrap().get(&short_channel_id).cloned();
2063+
let id_option = self.short_to_chan_info.read().unwrap().get(short_channel_id).cloned();
20642064
let mut channel_state = self.channel_state.lock().unwrap();
20652065
let forwarding_id_opt = match id_option {
20662066
None => { // unknown_next_peer
@@ -6782,7 +6782,7 @@ where
67826782
}
67836783
}
67846784

6785-
for (ref funding_txo, ref mut monitor) in args.channel_monitors.iter_mut() {
6785+
for (funding_txo, monitor) in args.channel_monitors.iter_mut() {
67866786
if !funding_txo_set.contains(funding_txo) {
67876787
log_info!(args.logger, "Broadcasting latest holder commitment transaction for closed channel {}", log_bytes!(funding_txo.to_channel_id()));
67886788
monitor.broadcast_latest_holder_commitment_txn(&args.tx_broadcaster, &args.logger);

0 commit comments

Comments
 (0)