@@ -323,7 +323,7 @@ impl ProbingStrategy for HighDegreeStrategy {
323323 let top_node_count = self . top_node_count . min ( nodes_by_degree. len ( ) ) ;
324324 let now = Instant :: now ( ) ;
325325
326- let mut probed = self . recently_probed . lock ( ) . unwrap ( ) ;
326+ let mut probed = self . recently_probed . lock ( ) . unwrap_or_else ( |e| e . into_inner ( ) ) ;
327327
328328 // We could check staleness when we use the entry, but that way we'd not clear cache at
329329 // all. For hundreds of top nodes it's okay to call retain each tick.
@@ -444,7 +444,7 @@ impl RandomStrategy {
444444 let graph = self . network_graph . read_only ( ) ;
445445 let first_hop =
446446 & initial_channels[ random_range ( 0 , initial_channels. len ( ) as u64 - 1 ) as usize ] ;
447- let first_hop_scid = first_hop. short_channel_id . unwrap ( ) ;
447+ let first_hop_scid = first_hop. short_channel_id ? ;
448448 let next_peer_pubkey = first_hop. counterparty . node_id ;
449449 let next_peer_node_id = NodeId :: from_pubkey ( & next_peer_pubkey) ;
450450
@@ -488,11 +488,15 @@ impl RandomStrategy {
488488 break ;
489489 } ;
490490 // Retrieve the direction-specific update via the public ChannelInfo fields.
491- // Safe to unwrap: as_directed_from already checked both directions are Some.
492- let update = if directed. source ( ) == & next_channel. node_one {
493- next_channel. one_to_two . as_ref ( ) . unwrap ( )
491+ // as_directed_from already checked both directions are Some, but we break
492+ // defensively rather than unwrap.
493+ let update = match if directed. source ( ) == & next_channel. node_one {
494+ next_channel. one_to_two . as_ref ( )
494495 } else {
495- next_channel. two_to_one . as_ref ( ) . unwrap ( )
496+ next_channel. two_to_one . as_ref ( )
497+ } {
498+ Some ( u) => u,
499+ None => break ,
496500 } ;
497501
498502 if !update. enabled {
@@ -560,10 +564,13 @@ impl RandomStrategy {
560564 let ( _, next_scid, _) = route[ i + 1 ] ;
561565 let next_channel = graph. channel ( next_scid) ?;
562566 let ( directed, _) = next_channel. as_directed_from ( & node_id) ?;
563- let update = if directed. source ( ) == & next_channel. node_one {
564- next_channel. one_to_two . as_ref ( ) . unwrap ( )
567+ let update = match if directed. source ( ) == & next_channel. node_one {
568+ next_channel. one_to_two . as_ref ( )
565569 } else {
566- next_channel. two_to_one . as_ref ( ) . unwrap ( )
570+ next_channel. two_to_one . as_ref ( )
571+ } {
572+ Some ( u) => u,
573+ None => return None ,
567574 } ;
568575 let fee = update. fees . base_msat as u64
569576 + ( forwarded * update. fees . proportional_millionths as u64 / 1_000_000 ) ;
0 commit comments