Skip to content

Commit 5fce9d2

Browse files
Extract macro for initial monitor persist
Makes handle_new_monitor_update more readable.
1 parent a54ef8e commit 5fce9d2

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,8 +3628,8 @@ macro_rules! handle_monitor_update_completion {
36283628
} }
36293629
}
36303630

3631-
macro_rules! handle_new_monitor_update {
3632-
($self: ident, $update_res: expr, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr, INITIAL_MONITOR) => {
3631+
macro_rules! handle_initial_monitor {
3632+
($self: ident, $update_res: expr, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr) => {
36333633
let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
36343634
let update_completed =
36353635
$self.handle_monitor_update_res($update_res, $chan.context.channel_id(), logger);
@@ -3643,6 +3643,9 @@ macro_rules! handle_new_monitor_update {
36433643
);
36443644
}
36453645
};
3646+
}
3647+
3648+
macro_rules! handle_new_monitor_update {
36463649
(
36473650
$self: ident, $funding_txo: expr, $update: expr, $peer_state: expr, $logger: expr,
36483651
$chan_id: expr, $counterparty_node_id: expr, $in_flight_updates: ident, $update_idx: ident,
@@ -10115,8 +10118,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1011510118
}
1011610119

1011710120
if let Some(funded_chan) = e.insert(Channel::from(chan)).as_funded_mut() {
10118-
handle_new_monitor_update!(self, persist_state, peer_state_lock, peer_state,
10119-
per_peer_state, funded_chan, INITIAL_MONITOR);
10121+
handle_initial_monitor!(self, persist_state, peer_state_lock, peer_state,
10122+
per_peer_state, funded_chan);
1012010123
} else {
1012110124
unreachable!("This must be a funded channel as we just inserted it.");
1012210125
}
@@ -10279,7 +10282,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1027910282
})
1028010283
{
1028110284
Ok((funded_chan, persist_status)) => {
10282-
handle_new_monitor_update!(self, persist_status, peer_state_lock, peer_state, per_peer_state, funded_chan, INITIAL_MONITOR);
10285+
handle_initial_monitor!(self, persist_status, peer_state_lock, peer_state, per_peer_state, funded_chan);
1028310286
Ok(())
1028410287
},
1028510288
Err(e) => try_channel_entry!(self, peer_state, Err(e), chan_entry),
@@ -10904,8 +10907,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1090410907
if let Some(monitor) = monitor_opt {
1090510908
let monitor_res = self.chain_monitor.watch_channel(monitor.channel_id(), monitor);
1090610909
if let Ok(persist_state) = monitor_res {
10907-
handle_new_monitor_update!(self, persist_state, peer_state_lock, peer_state,
10908-
per_peer_state, chan, INITIAL_MONITOR);
10910+
handle_initial_monitor!(self, persist_state, peer_state_lock, peer_state,
10911+
per_peer_state, chan);
1090910912
} else {
1091010913
let logger = WithChannelContext::from(&self.logger, &chan.context, None);
1091110914
log_error!(logger, "Persisting initial ChannelMonitor failed, implying the channel ID was duplicated");

0 commit comments

Comments
 (0)