@@ -751,8 +751,12 @@ impl P2pConnManager {
751751
752752 // Collect node information
753753 if config. include_node_info {
754- // Calculate location and adress if is set
755- let ( addr, location) = if let Some ( peer_id) =
754+ // Prefer the runtime's current ring location; fall back to derivation from the peer's
755+ // advertised address if we don't have one yet.
756+ let current_location =
757+ op_manager. ring . connection_manager . own_location ( ) . location ;
758+
759+ let ( addr, fallback_location) = if let Some ( peer_id) =
756760 op_manager. ring . connection_manager . get_peer_key ( )
757761 {
758762 let location = Location :: from_address ( & peer_id. addr ) ;
@@ -761,11 +765,15 @@ impl P2pConnManager {
761765 ( None , None )
762766 } ;
763767
768+ let location_str = current_location
769+ . or ( fallback_location)
770+ . map ( |loc| format ! ( "{:.6}" , loc. as_f64( ) ) ) ;
771+
764772 // Always include basic node info, but only include address/location if available
765773 response. node_info = Some ( NodeInfo {
766774 peer_id : ctx. key_pair . public ( ) . to_string ( ) ,
767775 is_gateway : self . is_gateway ,
768- location : location . map ( |loc| format ! ( "{:.6}" , loc . 0 ) ) ,
776+ location : location_str ,
769777 listening_address : addr
770778 . map ( |peer_addr| peer_addr. to_string ( ) ) ,
771779 uptime_seconds : 0 , // TODO: implement actual uptime tracking
@@ -1259,6 +1267,12 @@ impl P2pConnManager {
12591267 "connect_peer: registered new pending connection"
12601268 ) ;
12611269 state. outbound_handler . expect_incoming ( peer_addr) ;
1270+ let loc_hint = Location :: from_address ( & peer. addr ) ;
1271+ self . bridge
1272+ . op_manager
1273+ . ring
1274+ . connection_manager
1275+ . register_outbound_pending ( & peer, Some ( loc_hint) ) ;
12621276 }
12631277 }
12641278
@@ -1351,6 +1365,7 @@ impl P2pConnManager {
13511365 }
13521366 }
13531367
1368+ let mut derived_courtesy = courtesy;
13541369 let peer_id = peer. unwrap_or_else ( || {
13551370 tracing:: info!(
13561371 remote = %remote_addr,
@@ -1370,9 +1385,18 @@ impl P2pConnManager {
13701385 )
13711386 } ) ;
13721387
1388+ if !derived_courtesy {
1389+ derived_courtesy = self
1390+ . bridge
1391+ . op_manager
1392+ . ring
1393+ . connection_manager
1394+ . take_pending_courtesy_by_addr ( & remote_addr) ;
1395+ }
1396+
13731397 tracing:: info!(
13741398 remote = %peer_id. addr,
1375- courtesy,
1399+ courtesy = derived_courtesy ,
13761400 transaction = ?transaction,
13771401 "Inbound connection established"
13781402 ) ;
@@ -1383,7 +1407,7 @@ impl P2pConnManager {
13831407 state,
13841408 select_stream,
13851409 None ,
1386- courtesy ,
1410+ derived_courtesy ,
13871411 )
13881412 . await ?;
13891413 }
@@ -1598,13 +1622,13 @@ impl P2pConnManager {
15981622 }
15991623
16001624 if newly_inserted {
1601- let pending_loc = self
1625+ let loc = self
16021626 . bridge
16031627 . op_manager
16041628 . ring
16051629 . connection_manager
1606- . prune_in_transit_connection ( & peer_id) ;
1607- let loc = pending_loc . unwrap_or_else ( || Location :: from_address ( & peer_id. addr ) ) ;
1630+ . pending_location_hint ( & peer_id)
1631+ . unwrap_or_else ( || Location :: from_address ( & peer_id. addr ) ) ;
16081632 let eviction_candidate = self
16091633 . bridge
16101634 . op_manager
0 commit comments