Skip to content

Commit 705cd6f

Browse files
committed
Use optionally_notify in handle_splice_xxx (from review)
1 parent b85a9d7 commit 705cd6f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lightning/src/ln/channelmanager.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -11116,14 +11116,30 @@ where
1111611116

1111711117
#[cfg(splicing)]
1111811118
fn handle_splice_init(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceInit) {
11119-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
11120-
let _ = handle_error!(self, self.internal_splice_init(&counterparty_node_id, msg), counterparty_node_id);
11119+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
11120+
let res = self.internal_splice_init(&counterparty_node_id, msg);
11121+
let persist = match &res {
11122+
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
11123+
Err(_) => NotifyOption::SkipPersistHandleEvents,
11124+
Ok(()) => NotifyOption::SkipPersistNoEvents,
11125+
};
11126+
let _ = handle_error!(self, res, counterparty_node_id);
11127+
persist
11128+
});
1112111129
}
1112211130

1112311131
#[cfg(splicing)]
1112411132
fn handle_splice_ack(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceAck) {
11125-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
11126-
let _ = handle_error!(self, self.internal_splice_ack(&counterparty_node_id, msg), counterparty_node_id);
11133+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
11134+
let res = self.internal_splice_ack(&counterparty_node_id, msg);
11135+
let persist = match &res {
11136+
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
11137+
Err(_) => NotifyOption::SkipPersistHandleEvents,
11138+
Ok(()) => NotifyOption::SkipPersistNoEvents,
11139+
};
11140+
let _ = handle_error!(self, res, counterparty_node_id);
11141+
persist
11142+
});
1112711143
}
1112811144

1112911145
#[cfg(splicing)]

0 commit comments

Comments
 (0)