@@ -1614,10 +1614,10 @@ macro_rules! handle_error {
1614
1614
}
1615
1615
1616
1616
macro_rules! update_maps_on_chan_removal {
1617
- ( $self: expr, $channel : expr) => { {
1618
- $self. id_to_peer. lock( ) . unwrap( ) . remove( & $channel . context . channel_id( ) ) ;
1617
+ ( $self: expr, $channel_context : expr) => { {
1618
+ $self. id_to_peer. lock( ) . unwrap( ) . remove( & $channel_context . channel_id( ) ) ;
1619
1619
let mut short_to_chan_info = $self. short_to_chan_info. write( ) . unwrap( ) ;
1620
- if let Some ( short_id) = $channel . context . get_short_channel_id( ) {
1620
+ if let Some ( short_id) = $channel_context . get_short_channel_id( ) {
1621
1621
short_to_chan_info. remove( & short_id) ;
1622
1622
} else {
1623
1623
// If the channel was never confirmed on-chain prior to its closure, remove the
@@ -1626,10 +1626,10 @@ macro_rules! update_maps_on_chan_removal {
1626
1626
// also don't want a counterparty to be able to trivially cause a memory leak by simply
1627
1627
// opening a million channels with us which are closed before we ever reach the funding
1628
1628
// stage.
1629
- let alias_removed = $self. outbound_scid_aliases. lock( ) . unwrap( ) . remove( & $channel . context . outbound_scid_alias( ) ) ;
1629
+ let alias_removed = $self. outbound_scid_aliases. lock( ) . unwrap( ) . remove( & $channel_context . outbound_scid_alias( ) ) ;
1630
1630
debug_assert!( alias_removed) ;
1631
1631
}
1632
- short_to_chan_info. remove( & $channel . context . outbound_scid_alias( ) ) ;
1632
+ short_to_chan_info. remove( & $channel_context . outbound_scid_alias( ) ) ;
1633
1633
} }
1634
1634
}
1635
1635
@@ -1645,7 +1645,7 @@ macro_rules! convert_chan_err {
1645
1645
} ,
1646
1646
ChannelError :: Close ( msg) => {
1647
1647
log_error!( $self. logger, "Closing channel {} due to close-required error: {}" , log_bytes!( $channel_id[ ..] ) , msg) ;
1648
- update_maps_on_chan_removal!( $self, $channel) ;
1648
+ update_maps_on_chan_removal!( $self, & $channel. context ) ;
1649
1649
let shutdown_res = $channel. context. force_shutdown( true ) ;
1650
1650
( true , MsgHandleErrInternal :: from_finish_shutdown( msg, * $channel_id, $channel. context. get_user_id( ) ,
1651
1651
shutdown_res, $self. get_channel_update_for_broadcast( & $channel) . ok( ) ) )
@@ -1688,7 +1688,7 @@ macro_rules! remove_channel {
1688
1688
( $self: expr, $entry: expr) => {
1689
1689
{
1690
1690
let channel = $entry. remove_entry( ) . 1 ;
1691
- update_maps_on_chan_removal!( $self, channel) ;
1691
+ update_maps_on_chan_removal!( $self, & channel. context ) ;
1692
1692
channel
1693
1693
}
1694
1694
}
@@ -1810,7 +1810,7 @@ macro_rules! handle_new_monitor_update {
1810
1810
ChannelMonitorUpdateStatus :: PermanentFailure => {
1811
1811
log_error!( $self. logger, "Closing channel {} due to monitor update ChannelMonitorUpdateStatus::PermanentFailure" ,
1812
1812
log_bytes!( $chan. context. channel_id( ) [ ..] ) ) ;
1813
- update_maps_on_chan_removal!( $self, $chan) ;
1813
+ update_maps_on_chan_removal!( $self, & $chan. context ) ;
1814
1814
let res: Result <( ) , _> = Err ( MsgHandleErrInternal :: from_finish_shutdown(
1815
1815
"ChannelMonitor storage failure" . to_owned( ) , $chan. context. channel_id( ) ,
1816
1816
$chan. context. get_user_id( ) , $chan. context. force_shutdown( false ) ,
@@ -2798,6 +2798,7 @@ where
2798
2798
2799
2799
self . get_channel_update_for_onion ( short_channel_id, chan)
2800
2800
}
2801
+
2801
2802
fn get_channel_update_for_onion ( & self , short_channel_id : u64 , chan : & Channel < <SP :: Target as SignerProvider >:: Signer > ) -> Result < msgs:: ChannelUpdate , LightningError > {
2802
2803
log_trace ! ( self . logger, "Generating channel update for channel {}" , log_bytes!( chan. context. channel_id( ) ) ) ;
2803
2804
let were_node_one = self . our_network_pubkey . serialize ( ) [ ..] < chan. context . get_counterparty_node_id ( ) . serialize ( ) [ ..] ;
@@ -5826,7 +5827,7 @@ where
5826
5827
5827
5828
log_info ! ( self . logger, "Broadcasting {}" , log_tx!( tx) ) ;
5828
5829
self . tx_broadcaster . broadcast_transactions ( & [ & tx] ) ;
5829
- update_maps_on_chan_removal ! ( self , chan) ;
5830
+ update_maps_on_chan_removal ! ( self , & chan. context ) ;
5830
5831
false
5831
5832
} else { true }
5832
5833
} ,
@@ -6530,7 +6531,7 @@ where
6530
6531
}
6531
6532
}
6532
6533
} else if let Err ( reason) = res {
6533
- update_maps_on_chan_removal ! ( self , channel) ;
6534
+ update_maps_on_chan_removal ! ( self , & channel. context ) ;
6534
6535
// It looks like our counterparty went on-chain or funding transaction was
6535
6536
// reorged out of the main chain. Close the channel.
6536
6537
failed_channels. push ( channel. context . force_shutdown ( true ) ) ;
@@ -6790,7 +6791,7 @@ where
6790
6791
peer_state. channel_by_id . retain ( |_, chan| {
6791
6792
chan. remove_uncommitted_htlcs_and_mark_paused ( & self . logger ) ;
6792
6793
if chan. is_shutdown ( ) {
6793
- update_maps_on_chan_removal ! ( self , chan) ;
6794
+ update_maps_on_chan_removal ! ( self , & chan. context ) ;
6794
6795
self . issue_channel_close_events ( & chan. context , ClosureReason :: DisconnectedPeer ) ;
6795
6796
return false ;
6796
6797
}
0 commit comments