Skip to content

Commit feca83a

Browse files
committed
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).
1 parent e1c1ac7 commit feca83a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lightning/src/ln/functional_test_utils.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,17 @@ macro_rules! get_feerate {
259259

260260
macro_rules! get_local_commitment_txn {
261261
($node: expr, $channel_id: expr) => {
262-
$node.node.channel_state.lock().unwrap().by_id.get_mut(&$channel_id).unwrap().channel_monitor().get_latest_local_commitment_txn()
262+
{
263+
let mut monitors = $node.chan_monitor.simple_monitor.monitors.lock().unwrap();
264+
let mut commitment_txn = None;
265+
for (funding_txo, monitor) in monitors.iter_mut() {
266+
if funding_txo.to_channel_id() == $channel_id {
267+
commitment_txn = Some(monitor.get_latest_local_commitment_txn());
268+
break;
269+
}
270+
}
271+
commitment_txn.unwrap()
272+
}
263273
}
264274
}
265275

0 commit comments

Comments
 (0)