@@ -2777,18 +2777,16 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2777
2777
node_id : chan. get_counterparty_node_id ( ) ,
2778
2778
msg,
2779
2779
} ) ;
2780
- let chan_id = chan. channel_id ( ) ;
2781
- match channel_state. by_id . entry ( chan_id) {
2780
+ match channel_state. by_id . entry ( chan. channel_id ( ) ) {
2782
2781
hash_map:: Entry :: Occupied ( _) => {
2783
2782
panic ! ( "Generated duplicate funding txid?" ) ;
2784
2783
} ,
2785
2784
hash_map:: Entry :: Vacant ( e) => {
2786
- let counterparty_node_id = chan. get_counterparty_node_id ( ) ;
2787
- e. insert ( chan) ;
2788
2785
let mut id_to_peer = self . id_to_peer . lock ( ) . unwrap ( ) ;
2789
- if id_to_peer. insert ( chan_id , counterparty_node_id ) . is_some ( ) {
2786
+ if id_to_peer. insert ( chan . channel_id ( ) , chan . get_counterparty_node_id ( ) ) . is_some ( ) {
2790
2787
panic ! ( "id_to_peer map already contained funding txid, which shouldn't be possible" ) ;
2791
2788
}
2789
+ e. insert ( chan) ;
2792
2790
}
2793
2791
}
2794
2792
Ok ( ( ) )
@@ -4435,12 +4433,15 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4435
4433
}
4436
4434
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
4437
4435
let channel_state = & mut * channel_state_lock;
4438
- let channel_id = funding_msg. channel_id ;
4439
- match channel_state. by_id . entry ( channel_id) {
4436
+ match channel_state. by_id . entry ( funding_msg. channel_id ) {
4440
4437
hash_map:: Entry :: Occupied ( _) => {
4441
- return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Already had channel with the new channel_id" . to_owned ( ) , channel_id) )
4438
+ return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Already had channel with the new channel_id" . to_owned ( ) , funding_msg . channel_id ) )
4442
4439
} ,
4443
4440
hash_map:: Entry :: Vacant ( e) => {
4441
+ let mut id_to_peer = self . id_to_peer . lock ( ) . unwrap ( ) ;
4442
+ if id_to_peer. insert ( funding_msg. channel_id , * counterparty_node_id) . is_some ( ) {
4443
+ panic ! ( "id_to_peer map already contained funding txid, which shouldn't be possible" ) ;
4444
+ }
4444
4445
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendFundingSigned {
4445
4446
node_id : counterparty_node_id. clone ( ) ,
4446
4447
msg : funding_msg,
@@ -4449,10 +4450,6 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4449
4450
send_channel_ready ! ( channel_state. short_to_chan_info, channel_state. pending_msg_events, chan, msg) ;
4450
4451
}
4451
4452
e. insert ( chan) ;
4452
- let mut id_to_peer = self . id_to_peer . lock ( ) . unwrap ( ) ;
4453
- if id_to_peer. insert ( channel_id, * counterparty_node_id) . is_some ( ) {
4454
- panic ! ( "id_to_peer map already contained funding txid, which shouldn't be possible" ) ;
4455
- }
4456
4453
}
4457
4454
}
4458
4455
Ok ( ( ) )
0 commit comments