]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Swap loop and condition order to avoid looping unnecessarily
authorMatt Corallo <git@bluematt.me>
Tue, 7 Dec 2021 01:56:31 +0000 (01:56 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 21 Dec 2021 00:16:55 +0000 (00:16 +0000)
lightning/src/ln/channel.rs

index 98eb984fa4c3d6b07b9ea0e34f6c627d3f9fb8ea..e437d57aacca95a334b64846090ed99c5a6bf56f 100644 (file)
@@ -4367,8 +4367,8 @@ impl<Signer: Sign> Channel<Signer> {
                txdata: &TransactionData, genesis_block_hash: BlockHash, node_pk: PublicKey, logger: &L)
        -> Result<(Option<msgs::FundingLocked>, Option<msgs::AnnouncementSignatures>), ClosureReason> where L::Target: Logger {
                let non_shutdown_state = self.channel_state & (!MULTI_STATE_FLAGS);
-               for &(index_in_block, tx) in txdata.iter() {
-                       if let Some(funding_txo) = self.get_funding_txo() {
+               if let Some(funding_txo) = self.get_funding_txo() {
+                       for &(index_in_block, tx) in txdata.iter() {
                                // If we haven't yet sent a funding_locked, but are in FundingSent (ignoring
                                // whether they've sent a funding_locked or not), check if we should send one.
                                if non_shutdown_state & !(ChannelState::TheirFundingLocked as u32) == ChannelState::FundingSent as u32 {