@@ -4293,46 +4293,64 @@ where
4293
4293
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>,
4294
4294
funding_feerate_per_kw: u32, locktime: Option<u32>,
4295
4295
) -> Result<(), APIError> {
4296
- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4297
- let per_peer_state = self.per_peer_state.read().unwrap();
4296
+ let mut res = Ok(());
4297
+ PersistenceNotifierGuard::optionally_notify(self, || {
4298
+ let per_peer_state = self.per_peer_state.read().unwrap();
4298
4299
4299
- let peer_state_mutex = per_peer_state.get(counterparty_node_id)
4300
- .ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })?;
4300
+ let peer_state_mutex = match per_peer_state.get(counterparty_node_id)
4301
+ .ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) }) {
4302
+ Ok(p) => p,
4303
+ Err(e) => {
4304
+ res = Err(e);
4305
+ return NotifyOption::SkipPersistNoEvents;
4306
+ }
4307
+ };
4301
4308
4302
- let mut peer_state_lock = peer_state_mutex.lock().unwrap();
4303
- let peer_state = &mut *peer_state_lock;
4309
+ let mut peer_state_lock = peer_state_mutex.lock().unwrap();
4310
+ let peer_state = &mut *peer_state_lock;
4304
4311
4305
- // Look for the channel
4306
- match peer_state.channel_by_id.entry(*channel_id) {
4307
- hash_map::Entry::Occupied(mut chan_phase_entry) => {
4308
- let locktime = locktime.unwrap_or(self.current_best_block().height);
4309
- if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
4310
- let msg = chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs, funding_feerate_per_kw, locktime)?;
4312
+ // Look for the channel
4313
+ match peer_state.channel_by_id.entry(*channel_id) {
4314
+ hash_map::Entry::Occupied(mut chan_phase_entry) => {
4315
+ let locktime = locktime.unwrap_or(self.current_best_block().height);
4316
+ if let Some(chan) = chan_phase_entry.get_mut().as_funded_mut() {
4317
+ let msg = match chan.splice_channel(our_funding_contribution_satoshis, our_funding_inputs.clone(), funding_feerate_per_kw, locktime) {
4318
+ Ok(m) => m,
4319
+ Err(e) => {
4320
+ res = Err(e);
4321
+ return NotifyOption::SkipPersistNoEvents;
4322
+ }
4323
+ };
4311
4324
4312
- peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceInit {
4313
- node_id: *counterparty_node_id,
4314
- msg,
4315
- });
4325
+ peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceInit {
4326
+ node_id: *counterparty_node_id,
4327
+ msg,
4328
+ });
4316
4329
4317
- Ok(())
4318
- } else {
4319
- Err(APIError::ChannelUnavailable {
4330
+ res = Ok(());
4331
+ NotifyOption::SkipPersistHandleEvents
4332
+ } else {
4333
+ res = Err(APIError::ChannelUnavailable {
4334
+ err: format!(
4335
+ "Channel with id {} is not funded, cannot splice it",
4336
+ channel_id
4337
+ )
4338
+ });
4339
+ NotifyOption::SkipPersistNoEvents
4340
+ }
4341
+ },
4342
+ hash_map::Entry::Vacant(_) => {
4343
+ res = Err(APIError::ChannelUnavailable {
4320
4344
err: format!(
4321
- "Channel with id {} is not funded, cannot splice it ",
4322
- channel_id
4345
+ "Channel with id {} not found for the passed counterparty node_id {} ",
4346
+ channel_id, counterparty_node_id,
4323
4347
)
4324
- })
4325
- }
4326
- },
4327
- hash_map::Entry::Vacant(_) => {
4328
- return Err(APIError::ChannelUnavailable {
4329
- err: format!(
4330
- "Channel with id {} not found for the passed counterparty node_id {}",
4331
- channel_id, counterparty_node_id,
4332
- )
4333
- });
4334
- },
4335
- }
4348
+ });
4349
+ NotifyOption::SkipPersistNoEvents
4350
+ },
4351
+ }
4352
+ });
4353
+ res
4336
4354
}
4337
4355
4338
4356
fn can_forward_htlc_to_outgoing_channel(
0 commit comments