@@ -5537,14 +5537,20 @@ impl<SP: Deref> Channel<SP> where
5537
5537
}
5538
5538
}
5539
5539
5540
- pub fn channel_update(&mut self, msg: &msgs::ChannelUpdate) -> Result<(), ChannelError> {
5541
- self.context.counterparty_forwarding_info = Some(CounterpartyForwardingInfo {
5540
+ /// Applies the `ChannelUpdate` and returns a boolean indicating whether a change actually
5541
+ /// happened.
5542
+ pub fn channel_update(&mut self, msg: &msgs::ChannelUpdate) -> Result<bool, ChannelError> {
5543
+ let new_forwarding_info = Some(CounterpartyForwardingInfo {
5542
5544
fee_base_msat: msg.contents.fee_base_msat,
5543
5545
fee_proportional_millionths: msg.contents.fee_proportional_millionths,
5544
5546
cltv_expiry_delta: msg.contents.cltv_expiry_delta
5545
5547
});
5548
+ let did_change = self.context.counterparty_forwarding_info != new_forwarding_info;
5549
+ if did_change {
5550
+ self.context.counterparty_forwarding_info = new_forwarding_info;
5551
+ }
5546
5552
5547
- Ok(() )
5553
+ Ok(did_change )
5548
5554
}
5549
5555
5550
5556
/// Begins the shutdown process, getting a message for the remote peer and returning all
@@ -8140,7 +8146,7 @@ mod tests {
8140
8146
},
8141
8147
signature: Signature::from(unsafe { FFISignature::new() })
8142
8148
};
8143
- node_a_chan.channel_update(&update).unwrap();
8149
+ assert!( node_a_chan.channel_update(&update).unwrap() );
8144
8150
8145
8151
// The counterparty can send an update with a higher minimum HTLC, but that shouldn't
8146
8152
// change our official htlc_minimum_msat.
@@ -8153,6 +8159,8 @@ mod tests {
8153
8159
},
8154
8160
None => panic!("expected counterparty forwarding info to be Some")
8155
8161
}
8162
+
8163
+ assert!(!node_a_chan.channel_update(&update).unwrap());
8156
8164
}
8157
8165
8158
8166
#[cfg(feature = "_test_vectors")]
0 commit comments