]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Fetch latest commitment txn via monitor, not channel in test 2020-03-no-chan-mon
authorMatt Corallo <git@bluematt.me>
Thu, 19 Mar 2020 01:37:09 +0000 (21:37 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 19 Mar 2020 23:21:36 +0000 (19:21 -0400)
Eventually, we want to remove the Channel's copy of its own
ChannelMonitor, reducing memory footprint and complexity of
ChannelManager greatly.

This removes the last uses of said ChannelMonitor for latest
local commitment transactions (though it is still used for
would_broadcast_at_height(), which is the last remaining use).

lightning/src/ln/functional_test_utils.rs

index 746b6228cb3ab0ea79ae33d7bca7f685c7a18ab4..2da764b300b8bc2425aa7ff252fbba3749cdb7e9 100644 (file)
@@ -259,7 +259,17 @@ macro_rules! get_feerate {
 
 macro_rules! get_local_commitment_txn {
        ($node: expr, $channel_id: expr) => {
-               $node.node.channel_state.lock().unwrap().by_id.get_mut(&$channel_id).unwrap().channel_monitor().get_latest_local_commitment_txn()
+               {
+                       let mut monitors = $node.chan_monitor.simple_monitor.monitors.lock().unwrap();
+                       let mut commitment_txn = None;
+                       for (funding_txo, monitor) in monitors.iter_mut() {
+                               if funding_txo.to_channel_id() == $channel_id {
+                                       commitment_txn = Some(monitor.get_latest_local_commitment_txn());
+                                       break;
+                               }
+                       }
+                       commitment_txn.unwrap()
+               }
        }
 }