@@ -384,12 +384,7 @@ impl Actor {
384
384
}
385
385
Some ( new_conn) = self . conn_manager. next( ) => {
386
386
trace!( ?i, "tick: conn_manager" ) ;
387
- let node_id = new_conn. node_id;
388
- if let Err ( err) = self . handle_new_connection( new_conn) . await {
389
- warn!( peer=%node_id. fmt_short( ) , ?err, "failed to handle new connection" ) ;
390
- self . conn_manager. remove( & node_id) ;
391
- self . conn_send_tx. remove( & node_id) ;
392
- }
387
+ self . handle_new_connection( new_conn) . await ;
393
388
}
394
389
Some ( res) = self . conn_tasks. join_next( ) , if !self . conn_tasks. is_empty( ) => {
395
390
match res {
@@ -435,11 +430,11 @@ impl Actor {
435
430
async fn handle_to_actor_msg ( & mut self , msg : ToActor , now : Instant ) -> anyhow:: Result < ( ) > {
436
431
trace ! ( "handle to_actor {msg:?}" ) ;
437
432
match msg {
438
- ToActor :: AcceptConn ( conn) => {
439
- if let Err ( err) = self . conn_manager . push_accept ( conn ) {
440
- warn ! ( ?err , "failed to accept connection" ) ;
441
- }
442
- }
433
+ ToActor :: AcceptConn ( conn) => match self . conn_manager . accept ( conn ) {
434
+ Err ( err) => warn ! ( ?err , "failed to accept connection" ) ,
435
+ Ok ( None ) => { }
436
+ Ok ( Some ( conn ) ) => self . handle_new_connection ( conn ) . await ,
437
+ } ,
443
438
ToActor :: Join ( topic_id, peers, reply) => {
444
439
self . handle_in_event ( InEvent :: Command ( topic_id, Command :: Join ( peers) ) , now)
445
440
. await ?;
@@ -550,7 +545,7 @@ impl Actor {
550
545
Ok ( ( ) )
551
546
}
552
547
553
- async fn handle_new_connection ( & mut self , new_conn : NewConnection ) -> anyhow :: Result < ( ) > {
548
+ async fn handle_new_connection ( & mut self , new_conn : NewConnection ) {
554
549
let NewConnection {
555
550
conn,
556
551
node_id : peer_id,
@@ -582,8 +577,6 @@ impl Actor {
582
577
warn ! ( peer=%peer_id. fmt_short( ) , "connecting to node failed: {err:?}" ) ;
583
578
}
584
579
}
585
-
586
- Ok ( ( ) )
587
580
}
588
581
589
582
fn subscribe_all ( & mut self ) -> broadcast:: Receiver < ( TopicId , Event ) > {
0 commit comments