@@ -1517,18 +1517,6 @@ macro_rules! emit_channel_ready_event {
1517
1517
}
1518
1518
}
1519
1519
1520
- macro_rules! post_handle_chan_restoration {
1521
- ( $self: ident, $locked_res: expr, $counterparty_node_id: expr) => { {
1522
- let ( htlc_forwards, res) = $locked_res;
1523
-
1524
- let _ = handle_error!( $self, res, * $counterparty_node_id) ;
1525
-
1526
- if let Some ( forwards) = htlc_forwards {
1527
- $self. forward_htlcs( & mut [ forwards] [ ..] ) ;
1528
- }
1529
- } }
1530
- }
1531
-
1532
1520
impl < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > ChannelManager < M , T , K , F , L >
1533
1521
where M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
1534
1522
T :: Target : BroadcasterInterface ,
@@ -4381,69 +4369,66 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4381
4369
commitment_update : Option < msgs:: CommitmentUpdate > , order : RAACommitmentOrder ,
4382
4370
pending_forwards : Vec < ( PendingHTLCInfo , u64 ) > , funding_broadcastable : Option < Transaction > ,
4383
4371
channel_ready : Option < msgs:: ChannelReady > , announcement_sigs : Option < msgs:: AnnouncementSignatures > )
4384
- -> ( Option < ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 ) > ) > , Result < ( ) , MsgHandleErrInternal > ) {
4372
+ -> Option < ( u64 , OutPoint , Vec < ( PendingHTLCInfo , u64 ) > ) > {
4385
4373
let mut htlc_forwards = None ;
4386
4374
4387
4375
let counterparty_node_id = channel. get_counterparty_node_id ( ) ;
4388
- let res = loop {
4389
- if !pending_forwards. is_empty ( ) {
4390
- htlc_forwards = Some ( ( channel. get_short_channel_id ( ) . unwrap_or ( channel. outbound_scid_alias ( ) ) ,
4391
- channel. get_funding_txo ( ) . unwrap ( ) , pending_forwards) ) ;
4392
- }
4376
+ if !pending_forwards. is_empty ( ) {
4377
+ htlc_forwards = Some ( ( channel. get_short_channel_id ( ) . unwrap_or ( channel. outbound_scid_alias ( ) ) ,
4378
+ channel. get_funding_txo ( ) . unwrap ( ) , pending_forwards) ) ;
4379
+ }
4393
4380
4394
- if let Some ( msg) = channel_ready {
4395
- send_channel_ready ! ( self , pending_msg_events, channel, msg) ;
4396
- }
4397
- if let Some ( msg) = announcement_sigs {
4398
- pending_msg_events. push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
4381
+ if let Some ( msg) = channel_ready {
4382
+ send_channel_ready ! ( self , pending_msg_events, channel, msg) ;
4383
+ }
4384
+ if let Some ( msg) = announcement_sigs {
4385
+ pending_msg_events. push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
4386
+ node_id : counterparty_node_id,
4387
+ msg,
4388
+ } ) ;
4389
+ }
4390
+
4391
+ emit_channel_ready_event ! ( self , channel) ;
4392
+
4393
+ macro_rules! handle_cs { ( ) => {
4394
+ if let Some ( update) = commitment_update {
4395
+ pending_msg_events. push( events:: MessageSendEvent :: UpdateHTLCs {
4399
4396
node_id: counterparty_node_id,
4400
- msg ,
4397
+ updates : update ,
4401
4398
} ) ;
4402
4399
}
4403
-
4404
- emit_channel_ready_event ! ( self , channel) ;
4405
-
4406
- macro_rules! handle_cs { ( ) => {
4407
- if let Some ( update) = commitment_update {
4408
- pending_msg_events. push( events:: MessageSendEvent :: UpdateHTLCs {
4409
- node_id: counterparty_node_id,
4410
- updates: update,
4411
- } ) ;
4412
- }
4413
- } }
4414
- macro_rules! handle_raa { ( ) => {
4415
- if let Some ( revoke_and_ack) = raa {
4416
- pending_msg_events. push( events:: MessageSendEvent :: SendRevokeAndACK {
4417
- node_id: counterparty_node_id,
4418
- msg: revoke_and_ack,
4419
- } ) ;
4420
- }
4421
- } }
4422
- match order {
4423
- RAACommitmentOrder :: CommitmentFirst => {
4424
- handle_cs ! ( ) ;
4425
- handle_raa ! ( ) ;
4426
- } ,
4427
- RAACommitmentOrder :: RevokeAndACKFirst => {
4428
- handle_raa ! ( ) ;
4429
- handle_cs ! ( ) ;
4430
- } ,
4400
+ } }
4401
+ macro_rules! handle_raa { ( ) => {
4402
+ if let Some ( revoke_and_ack) = raa {
4403
+ pending_msg_events. push( events:: MessageSendEvent :: SendRevokeAndACK {
4404
+ node_id: counterparty_node_id,
4405
+ msg: revoke_and_ack,
4406
+ } ) ;
4431
4407
}
4408
+ } }
4409
+ match order {
4410
+ RAACommitmentOrder :: CommitmentFirst => {
4411
+ handle_cs ! ( ) ;
4412
+ handle_raa ! ( ) ;
4413
+ } ,
4414
+ RAACommitmentOrder :: RevokeAndACKFirst => {
4415
+ handle_raa ! ( ) ;
4416
+ handle_cs ! ( ) ;
4417
+ } ,
4418
+ }
4432
4419
4433
- if let Some ( tx) = funding_broadcastable {
4434
- log_info ! ( self . logger, "Broadcasting funding transaction with txid {}" , tx. txid( ) ) ;
4435
- self . tx_broadcaster . broadcast_transaction ( & tx) ;
4436
- }
4437
- break Ok ( ( ) ) ;
4438
- } ;
4420
+ if let Some ( tx) = funding_broadcastable {
4421
+ log_info ! ( self . logger, "Broadcasting funding transaction with txid {}" , tx. txid( ) ) ;
4422
+ self . tx_broadcaster . broadcast_transaction ( & tx) ;
4423
+ }
4439
4424
4440
- ( htlc_forwards, res )
4425
+ htlc_forwards
4441
4426
}
4442
4427
4443
4428
fn channel_monitor_updated ( & self , funding_txo : & OutPoint , highest_applied_update_id : u64 ) {
4444
4429
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
4445
4430
4446
- let chan_restoration_res ;
4431
+ let htlc_forwards ;
4447
4432
let ( mut pending_failures, finalized_claims, counterparty_node_id) = {
4448
4433
let mut channel_lock = self . channel_state . lock ( ) . unwrap ( ) ;
4449
4434
let channel_state = & mut * channel_lock;
@@ -4470,14 +4455,16 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4470
4455
} )
4471
4456
} else { None }
4472
4457
} else { None } ;
4473
- chan_restoration_res = self . handle_channel_resumption ( & mut channel_state. pending_msg_events , channel. get_mut ( ) , updates. raa , updates. commitment_update , updates. order , updates. accepted_htlcs , updates. funding_broadcastable , updates. channel_ready , updates. announcement_sigs ) ;
4458
+ htlc_forwards = self . handle_channel_resumption ( & mut channel_state. pending_msg_events , channel. get_mut ( ) , updates. raa , updates. commitment_update , updates. order , updates. accepted_htlcs , updates. funding_broadcastable , updates. channel_ready , updates. announcement_sigs ) ;
4474
4459
if let Some ( upd) = channel_update {
4475
4460
channel_state. pending_msg_events . push ( upd) ;
4476
4461
}
4477
4462
4478
4463
( updates. failed_htlcs , updates. finalized_claimed_htlcs , counterparty_node_id)
4479
4464
} ;
4480
- post_handle_chan_restoration ! ( self , chan_restoration_res, & counterparty_node_id) ;
4465
+ if let Some ( forwards) = htlc_forwards {
4466
+ self . forward_htlcs ( & mut [ forwards] [ ..] ) ;
4467
+ }
4481
4468
self . finalize_claims ( finalized_claims) ;
4482
4469
for failure in pending_failures. drain ( ..) {
4483
4470
let receiver = HTLCDestination :: NextHopChannel { node_id : Some ( counterparty_node_id) , channel_id : funding_txo. to_channel_id ( ) } ;
@@ -5228,7 +5215,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5228
5215
}
5229
5216
5230
5217
fn internal_channel_reestablish ( & self , counterparty_node_id : & PublicKey , msg : & msgs:: ChannelReestablish ) -> Result < ( ) , MsgHandleErrInternal > {
5231
- let chan_restoration_res ;
5218
+ let htlc_forwards ;
5232
5219
let need_lnd_workaround = {
5233
5220
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
5234
5221
let channel_state = & mut * channel_state_lock;
@@ -5263,7 +5250,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5263
5250
}
5264
5251
}
5265
5252
let need_lnd_workaround = chan. get_mut ( ) . workaround_lnd_bug_4006 . take ( ) ;
5266
- chan_restoration_res = self . handle_channel_resumption (
5253
+ htlc_forwards = self . handle_channel_resumption (
5267
5254
& mut channel_state. pending_msg_events , chan. get_mut ( ) , responses. raa , responses. commitment_update , responses. order ,
5268
5255
Vec :: new ( ) , None , responses. channel_ready , responses. announcement_sigs ) ;
5269
5256
if let Some ( upd) = channel_update {
@@ -5274,7 +5261,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5274
5261
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
5275
5262
}
5276
5263
} ;
5277
- post_handle_chan_restoration ! ( self , chan_restoration_res, counterparty_node_id) ;
5264
+
5265
+ if let Some ( forwards) = htlc_forwards {
5266
+ self . forward_htlcs ( & mut [ forwards] [ ..] ) ;
5267
+ }
5278
5268
5279
5269
if let Some ( channel_ready_msg) = need_lnd_workaround {
5280
5270
self . internal_channel_ready ( counterparty_node_id, & channel_ready_msg) ?;
0 commit comments