@@ -257,6 +257,7 @@ impl OutboundJITChannel {
257
257
struct PeerState {
258
258
outbound_channels_by_intercept_scid : HashMap < u64 , OutboundJITChannel > ,
259
259
intercept_scid_by_user_channel_id : HashMap < u128 , u64 > ,
260
+ intercept_scid_by_channel_id : HashMap < ChannelId , u64 > ,
260
261
pending_requests : HashMap < RequestId , LSPS2Request > ,
261
262
}
262
263
@@ -265,10 +266,12 @@ impl PeerState {
265
266
let outbound_channels_by_intercept_scid = HashMap :: new ( ) ;
266
267
let pending_requests = HashMap :: new ( ) ;
267
268
let intercept_scid_by_user_channel_id = HashMap :: new ( ) ;
269
+ let intercept_scid_by_channel_id = HashMap :: new ( ) ;
268
270
Self {
269
271
outbound_channels_by_intercept_scid,
270
272
pending_requests,
271
273
intercept_scid_by_user_channel_id,
274
+ intercept_scid_by_channel_id,
272
275
}
273
276
}
274
277
@@ -287,6 +290,7 @@ where
287
290
pending_events : Arc < EventQueue > ,
288
291
per_peer_state : RwLock < HashMap < PublicKey , Mutex < PeerState > > > ,
289
292
peer_by_intercept_scid : RwLock < HashMap < u64 , PublicKey > > ,
293
+ peer_by_channel_id : RwLock < HashMap < ChannelId , PublicKey > > ,
290
294
config : LSPS2ServiceConfig ,
291
295
}
292
296
@@ -304,6 +308,7 @@ where
304
308
pending_events,
305
309
per_peer_state : RwLock :: new ( HashMap :: new ( ) ) ,
306
310
peer_by_intercept_scid : RwLock :: new ( HashMap :: new ( ) ) ,
311
+ peer_by_channel_id : RwLock :: new ( HashMap :: new ( ) ) ,
307
312
channel_manager,
308
313
config,
309
314
}
@@ -523,13 +528,18 @@ where
523
528
pub fn channel_ready (
524
529
& self , user_channel_id : u128 , channel_id : & ChannelId , counterparty_node_id : & PublicKey ,
525
530
) -> Result < ( ) , APIError > {
531
+ {
532
+ let mut peer_by_channel_id = self . peer_by_channel_id . write ( ) . unwrap ( ) ;
533
+ peer_by_channel_id. insert ( * channel_id, * counterparty_node_id) ;
534
+ }
526
535
let outer_state_lock = self . per_peer_state . read ( ) . unwrap ( ) ;
527
536
match outer_state_lock. get ( counterparty_node_id) {
528
537
Some ( inner_state_lock) => {
529
538
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
530
539
if let Some ( intercept_scid) =
531
540
peer_state. intercept_scid_by_user_channel_id . get ( & user_channel_id) . copied ( )
532
541
{
542
+ peer_state. intercept_scid_by_channel_id . insert ( * channel_id, intercept_scid) ;
533
543
if let Some ( jit_channel) =
534
544
peer_state. outbound_channels_by_intercept_scid . get_mut ( & intercept_scid)
535
545
{
0 commit comments