Skip to content

Commit 1152488

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 7bdbbca commit 1152488

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lightning/src/chain/onchaintx.rs

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

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ where
21022102
// short_channel_id is non-0 in any ::Forward.
21032103
if let &PendingHTLCRouting::Forward { ref short_channel_id, .. } = routing {
21042104
if let Some((err, mut code, chan_update)) = loop {
2105-
let id_option = self.short_to_chan_info.read().unwrap().get(&short_channel_id).cloned();
2105+
let id_option = self.short_to_chan_info.read().unwrap().get(short_channel_id).cloned();
21062106
let forwarding_chan_info_opt = match id_option {
21072107
None => { // unknown_next_peer
21082108
// Note that this is likely a timing oracle for detecting whether an scid is a
@@ -7116,7 +7116,7 @@ where
71167116
}
71177117
}
71187118

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

0 commit comments

Comments
 (0)