Skip to content

Commit 6c58a73

Browse files
committed
f - Look up in HashMap rather than iterate over it in spends_watched_output
1 parent 7e2a0dc commit 6c58a73

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,9 +2017,9 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
20172017
/// Checks if a given transaction spends any watched outputs.
20182018
fn spends_watched_output(&self, tx: &Transaction) -> bool {
20192019
for input in tx.input.iter() {
2020-
for (txid, outputs) in self.get_outputs_to_watch().iter() {
2020+
if let Some(outputs) = self.get_outputs_to_watch().get(&input.previous_output.txid) {
20212021
for (idx, _script_pubkey) in outputs.iter().enumerate() {
2022-
if txid == &input.previous_output.txid && idx == input.previous_output.vout as usize {
2022+
if idx == input.previous_output.vout as usize {
20232023
return true;
20242024
}
20252025
}

0 commit comments

Comments
 (0)