Skip to content

Commit b81c0e4

Browse files
committed
Use optionally_notify in handle_splice_xxx (from review)
1 parent 7e2694f commit b81c0e4

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
@@ -11152,14 +11152,30 @@ where
1115211152

1115311153
#[cfg(splicing)]
1115411154
fn handle_splice_init(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceInit) {
11155-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
11156-
let _ = handle_error!(self, self.internal_splice_init(&counterparty_node_id, msg), counterparty_node_id);
11155+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
11156+
let res = self.internal_splice_init(&counterparty_node_id, msg);
11157+
let persist = match &res {
11158+
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
11159+
Err(_) => NotifyOption::SkipPersistHandleEvents,
11160+
Ok(()) => NotifyOption::SkipPersistNoEvents,
11161+
};
11162+
let _ = handle_error!(self, res, counterparty_node_id);
11163+
persist
11164+
});
1115711165
}
1115811166

1115911167
#[cfg(splicing)]
1116011168
fn handle_splice_ack(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceAck) {
11161-
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
11162-
let _ = handle_error!(self, self.internal_splice_ack(&counterparty_node_id, msg), counterparty_node_id);
11169+
let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
11170+
let res = self.internal_splice_ack(&counterparty_node_id, msg);
11171+
let persist = match &res {
11172+
Err(e) if e.closes_channel() => NotifyOption::DoPersist,
11173+
Err(_) => NotifyOption::SkipPersistHandleEvents,
11174+
Ok(()) => NotifyOption::SkipPersistNoEvents,
11175+
};
11176+
let _ = handle_error!(self, res, counterparty_node_id);
11177+
persist
11178+
});
1116311179
}
1116411180

1116511181
#[cfg(splicing)]

0 commit comments

Comments
 (0)