@@ -200,7 +200,7 @@ impl NodeMap {
200
200
. expect ( "poisoned" )
201
201
. get_mut ( NodeStateKey :: Idx ( id) )
202
202
{
203
- ep. ping_timeout ( tx_id) ;
203
+ ep. ping_timeout ( tx_id, Instant :: now ( ) ) ;
204
204
}
205
205
}
206
206
@@ -277,9 +277,10 @@ impl NodeMap {
277
277
}
278
278
279
279
pub ( super ) fn reset_node_states ( & self ) {
280
+ let now = Instant :: now ( ) ;
280
281
let mut inner = self . inner . lock ( ) . expect ( "poisoned" ) ;
281
282
for ( _, ep) in inner. node_states_mut ( ) {
282
- ep. note_connectivity_change ( ) ;
283
+ ep. note_connectivity_change ( now ) ;
283
284
}
284
285
}
285
286
@@ -328,7 +329,7 @@ impl NodeMap {
328
329
self . inner
329
330
. lock ( )
330
331
. expect ( "poisoned" )
331
- . on_direct_addr_discovered ( discovered) ;
332
+ . on_direct_addr_discovered ( discovered, Instant :: now ( ) ) ;
332
333
}
333
334
}
334
335
@@ -389,18 +390,22 @@ impl NodeMapInner {
389
390
}
390
391
391
392
/// Prunes direct addresses from nodes that claim to share an address we know points to us.
392
- pub ( super ) fn on_direct_addr_discovered ( & mut self , discovered : BTreeSet < SocketAddr > ) {
393
+ pub ( super ) fn on_direct_addr_discovered (
394
+ & mut self ,
395
+ discovered : BTreeSet < SocketAddr > ,
396
+ now : Instant ,
397
+ ) {
393
398
for addr in discovered {
394
- self . remove_by_ipp ( addr. into ( ) , ClearReason :: MatchesOurLocalAddr )
399
+ self . remove_by_ipp ( addr. into ( ) , ClearReason :: MatchesOurLocalAddr , now )
395
400
}
396
401
}
397
402
398
403
/// Removes a direct address from a node.
399
- fn remove_by_ipp ( & mut self , ipp : IpPort , reason : ClearReason ) {
404
+ fn remove_by_ipp ( & mut self , ipp : IpPort , reason : ClearReason , now : Instant ) {
400
405
if let Some ( id) = self . by_ip_port . remove ( & ipp) {
401
406
if let Entry :: Occupied ( mut entry) = self . by_id . entry ( id) {
402
407
let node = entry. get_mut ( ) ;
403
- node. remove_direct_addr ( & ipp, reason) ;
408
+ node. remove_direct_addr ( & ipp, reason, now ) ;
404
409
if node. direct_addresses ( ) . count ( ) == 0 {
405
410
let node_id = node. public_key ( ) ;
406
411
let mapped_addr = node. quic_mapped_addr ( ) ;
@@ -853,7 +858,7 @@ mod tests {
853
858
}
854
859
855
860
info ! ( "Pruning addresses" ) ;
856
- endpoint. prune_direct_addresses ( ) ;
861
+ endpoint. prune_direct_addresses ( Instant :: now ( ) ) ;
857
862
858
863
// Half the offline addresses should have been pruned. All the active and alive
859
864
// addresses should have been kept.
0 commit comments