From feca83a8a8e3942445b41a2066f03a1d9210d723 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 18 Mar 2020 21:37:09 -0400 Subject: [PATCH] Fetch latest commitment txn via monitor, not channel in test 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 746b6228c..2da764b30 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -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() + } } } -- 2.39.5