@@ -8,15 +8,14 @@ use std::{
8
8
use iroh_base:: { NodeAddr , NodeId , PublicKey , RelayUrl } ;
9
9
use n0_future:: time:: Instant ;
10
10
use serde:: { Deserialize , Serialize } ;
11
- use stun_rs:: TransactionId ;
12
11
use tracing:: { debug, info, instrument, trace, warn} ;
13
12
14
13
use self :: {
15
14
best_addr:: ClearReason ,
16
- node_state:: { NodeState , Options , PingHandled } ,
15
+ node_state:: { NodeState , Options } ,
17
16
} ;
18
- use super :: { metrics:: Metrics , transports , ActorMessage , NodeIdMappedAddr } ;
19
- use crate :: disco:: { CallMeMaybe , Pong , SendAddr } ;
17
+ use super :: { metrics:: Metrics , NodeIdMappedAddr } ;
18
+ use crate :: disco:: CallMeMaybe ;
20
19
#[ cfg( any( test, feature = "test-utils" ) ) ]
21
20
use crate :: endpoint:: PathSelection ;
22
21
@@ -25,8 +24,8 @@ mod node_state;
25
24
mod path_state;
26
25
mod udp_paths;
27
26
27
+ pub ( super ) use node_state:: PingAction ;
28
28
pub use node_state:: { ConnectionType , ControlMsg , DirectAddrInfo , RemoteInfo } ;
29
- pub ( super ) use node_state:: { DiscoPingPurpose , PingAction , PingRole , SendPing } ;
30
29
31
30
/// Number of nodes that are inactive for which we keep info about. This limit is enforced
32
31
/// periodically via [`NodeMap::prune_inactive`].
@@ -71,7 +70,6 @@ pub(super) struct NodeMapInner {
71
70
/// have for the node. These are all the keys the [`NodeMap`] can use.
72
71
#[ derive( Debug , Clone ) ]
73
72
enum NodeStateKey {
74
- Idx ( usize ) ,
75
73
NodeId ( NodeId ) ,
76
74
NodeIdMappedAddr ( NodeIdMappedAddr ) ,
77
75
IpPort ( IpPort ) ,
@@ -171,35 +169,6 @@ impl NodeMap {
171
169
. receive_relay ( relay_url, src)
172
170
}
173
171
174
- pub ( super ) fn notify_ping_sent (
175
- & self ,
176
- id : usize ,
177
- dst : SendAddr ,
178
- tx_id : stun_rs:: TransactionId ,
179
- purpose : DiscoPingPurpose ,
180
- msg_sender : tokio:: sync:: mpsc:: Sender < ActorMessage > ,
181
- ) {
182
- if let Some ( ep) = self
183
- . inner
184
- . lock ( )
185
- . expect ( "poisoned" )
186
- . get_mut ( NodeStateKey :: Idx ( id) )
187
- {
188
- ep. ping_sent ( dst, tx_id, purpose, msg_sender) ;
189
- }
190
- }
191
-
192
- pub ( super ) fn notify_ping_timeout ( & self , id : usize , tx_id : stun_rs:: TransactionId ) {
193
- if let Some ( ep) = self
194
- . inner
195
- . lock ( )
196
- . expect ( "poisoned" )
197
- . get_mut ( NodeStateKey :: Idx ( id) )
198
- {
199
- ep. ping_timeout ( tx_id) ;
200
- }
201
- }
202
-
203
172
pub ( super ) fn get_quic_mapped_addr_for_node_key (
204
173
& self ,
205
174
node_key : NodeId ,
@@ -211,38 +180,16 @@ impl NodeMap {
211
180
. map ( |ep| * ep. quic_mapped_addr ( ) )
212
181
}
213
182
214
- /// Insert a received ping into the node map, and return whether a ping with this tx_id was already
215
- /// received.
216
- pub ( super ) fn handle_ping (
217
- & self ,
218
- sender : PublicKey ,
219
- src : SendAddr ,
220
- tx_id : TransactionId ,
221
- ) -> PingHandled {
222
- self . inner
223
- . lock ( )
224
- . expect ( "poisoned" )
225
- . handle_ping ( sender, src, tx_id)
226
- }
227
-
228
- pub ( super ) fn handle_pong ( & self , sender : PublicKey , src : & transports:: Addr , pong : Pong ) {
229
- self . inner
230
- . lock ( )
231
- . expect ( "poisoned" )
232
- . handle_pong ( sender, src, pong)
233
- }
234
-
235
- #[ must_use = "actions must be handled" ]
236
183
pub ( super ) fn handle_call_me_maybe (
237
184
& self ,
238
185
sender : PublicKey ,
239
186
cm : CallMeMaybe ,
240
187
metrics : & Metrics ,
241
- ) -> Vec < PingAction > {
188
+ ) {
242
189
self . inner
243
190
. lock ( )
244
191
. expect ( "poisoned" )
245
- . handle_call_me_maybe ( sender, cm, metrics)
192
+ . handle_call_me_maybe ( sender, cm, metrics) ;
246
193
}
247
194
248
195
#[ allow( clippy:: type_complexity) ]
@@ -404,7 +351,6 @@ impl NodeMapInner {
404
351
405
352
fn get_id ( & self , id : NodeStateKey ) -> Option < usize > {
406
353
match id {
407
- NodeStateKey :: Idx ( id) => Some ( id) ,
408
354
NodeStateKey :: NodeId ( node_key) => self . by_node_key . get ( & node_key) . copied ( ) ,
409
355
NodeStateKey :: NodeIdMappedAddr ( addr) => self . by_quic_mapped_addr . get ( & addr) . copied ( ) ,
410
356
NodeStateKey :: IpPort ( ipp) => self . by_ip_port . get ( & ipp) . copied ( ) ,
@@ -500,25 +446,7 @@ impl NodeMapInner {
500
446
. map ( |ep| ep. conn_type ( ) )
501
447
}
502
448
503
- fn handle_pong ( & mut self , sender : NodeId , src : & transports:: Addr , pong : Pong ) {
504
- if let Some ( ns) = self . get_mut ( NodeStateKey :: NodeId ( sender) ) . as_mut ( ) {
505
- let insert = ns. handle_pong ( & pong, src. clone ( ) . into ( ) ) ;
506
- if let Some ( ( src, key) ) = insert {
507
- self . set_node_key_for_ip_port ( src, & key) ;
508
- }
509
- trace ! ( ?insert, "received pong" )
510
- } else {
511
- warn ! ( "received pong: node unknown, ignore" )
512
- }
513
- }
514
-
515
- #[ must_use = "actions must be handled" ]
516
- fn handle_call_me_maybe (
517
- & mut self ,
518
- sender : NodeId ,
519
- cm : CallMeMaybe ,
520
- metrics : & Metrics ,
521
- ) -> Vec < PingAction > {
449
+ fn handle_call_me_maybe ( & mut self , sender : NodeId , cm : CallMeMaybe , metrics : & Metrics ) {
522
450
let ns_id = NodeStateKey :: NodeId ( sender) ;
523
451
if let Some ( id) = self . get_id ( ns_id. clone ( ) ) {
524
452
for number in & cm. my_numbers {
@@ -530,43 +458,13 @@ impl NodeMapInner {
530
458
None => {
531
459
debug ! ( "received call-me-maybe: ignore, node is unknown" ) ;
532
460
metrics. recv_disco_call_me_maybe_bad_disco . inc ( ) ;
533
- vec ! [ ]
534
461
}
535
462
Some ( ns) => {
536
463
debug ! ( endpoints = ?cm. my_numbers, "received call-me-maybe" ) ;
537
464
538
- ns. handle_call_me_maybe ( cm)
539
- }
540
- }
541
- }
542
-
543
- fn handle_ping ( & mut self , sender : NodeId , src : SendAddr , tx_id : TransactionId ) -> PingHandled {
544
- #[ cfg( any( test, feature = "test-utils" ) ) ]
545
- let path_selection = self . path_selection ;
546
- let node_state = self . get_or_insert_with ( NodeStateKey :: NodeId ( sender) , || {
547
- debug ! ( "received ping: node unknown, add to node map" ) ;
548
- let source = if src. is_relay ( ) {
549
- Source :: Relay
550
- } else {
551
- Source :: Udp
552
- } ;
553
- Options {
554
- node_id : sender,
555
- relay_url : src. relay_url ( ) ,
556
- active : true ,
557
- source,
558
- #[ cfg( any( test, feature = "test-utils" ) ) ]
559
- path_selection,
560
- }
561
- } ) ;
562
-
563
- let handled = node_state. handle_ping ( src. clone ( ) , tx_id) ;
564
- if let SendAddr :: Udp ( ref addr) = src {
565
- if matches ! ( handled. role, PingRole :: NewPath ) {
566
- self . set_node_key_for_ip_port ( * addr, & sender) ;
465
+ ns. handle_call_me_maybe ( cm) ;
567
466
}
568
467
}
569
- handled
570
468
}
571
469
572
470
/// Inserts a new node into the [`NodeMap`].
@@ -704,6 +602,7 @@ mod tests {
704
602
use tracing_test:: traced_test;
705
603
706
604
use super :: { node_state:: MAX_INACTIVE_DIRECT_ADDRESSES , * } ;
605
+ use crate :: disco:: SendAddr ;
707
606
708
607
impl NodeMap {
709
608
#[ track_caller]
@@ -836,7 +735,7 @@ mod tests {
836
735
let txid = stun_rs:: TransactionId :: from ( [ i as u8 ; 12 ] ) ;
837
736
// Note that this already invokes .prune_direct_addresses() because these are
838
737
// new UDP paths.
839
- endpoint. handle_ping ( addr, txid) ;
738
+ // endpoint.handle_ping(addr, txid);
840
739
}
841
740
842
741
info ! ( "Pruning addresses" ) ;
0 commit comments