Skip to content

Commit 2030861

Browse files
committed
fix Persist flag simplification in splice_channel
1 parent 719189e commit 2030861

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,13 +4287,13 @@ where
42874287
&self, channel_id: &ChannelId, counterparty_node_id: &PublicKey, our_funding_contribution_satoshis: i64,
42884288
our_funding_inputs: &Vec<(TxIn, Transaction, Weight)>,
42894289
funding_feerate_per_kw: u32, locktime: Option<u32>,
4290-
) -> (Result<(), APIError>, NotifyOption) {
4290+
) -> Result<(), APIError> {
42914291
let per_peer_state = self.per_peer_state.read().unwrap();
42924292

42934293
let peer_state_mutex = match per_peer_state.get(counterparty_node_id)
42944294
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) }) {
42954295
Ok(p) => p,
4296-
Err(e) => return (Err(e), NotifyOption::SkipPersistNoEvents),
4296+
Err(e) => return Err(e),
42974297
};
42984298

42994299
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -4306,31 +4306,31 @@ where
43064306
if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
43074307
let msg = match chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs, funding_feerate_per_kw, locktime) {
43084308
Ok(m) => m,
4309-
Err(e) => return (Err(e), NotifyOption::SkipPersistNoEvents),
4309+
Err(e) => return Err(e),
43104310
};
43114311

43124312
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceInit {
43134313
node_id: *counterparty_node_id,
43144314
msg,
43154315
});
43164316

4317-
(Ok(()), NotifyOption::SkipPersistHandleEvents)
4317+
Ok(())
43184318
} else {
4319-
(Err(APIError::ChannelUnavailable {
4319+
Err(APIError::ChannelUnavailable {
43204320
err: format!(
43214321
"Channel with id {} is not funded, cannot splice it",
43224322
channel_id
43234323
)
4324-
}), NotifyOption::SkipPersistNoEvents)
4324+
})
43254325
}
43264326
},
43274327
hash_map::Entry::Vacant(_) => {
4328-
(Err(APIError::ChannelUnavailable {
4328+
Err(APIError::ChannelUnavailable {
43294329
err: format!(
43304330
"Channel with id {} not found for the passed counterparty node_id {}",
43314331
channel_id, counterparty_node_id,
43324332
)
4333-
}), NotifyOption::SkipPersistNoEvents)
4333+
})
43344334
},
43354335
}
43364336
}
@@ -4354,11 +4354,14 @@ where
43544354
) -> Result<(), APIError> {
43554355
let mut res = Ok(());
43564356
PersistenceNotifierGuard::optionally_notify(self, || {
4357-
let (result, notify_option) = self.internal_splice_channel(
4357+
let result = self.internal_splice_channel(
43584358
channel_id, counterparty_node_id, our_funding_contribution_satoshis, &our_funding_inputs, funding_feerate_per_kw, locktime
43594359
);
43604360
res = result;
4361-
notify_option
4361+
match res {
4362+
Ok(_) => NotifyOption::SkipPersistHandleEvents,
4363+
Err(_) => NotifyOption::SkipPersistNoEvents,
4364+
}
43624365
});
43634366
res
43644367
}

0 commit comments

Comments
 (0)