pub(crate) fn handle_dial_outcome(
        &mut self,
        dial_outcome: DialOutcome<H, E>,
    ) -> Option<DialRequest<H>> {
        let addr = dial_outcome.addr();
        let span = make_span(addr, self.outgoing.get(&addr));

        span.clone().in_scope(move || match dial_outcome {
            DialOutcome::Successful {
                addr,
                handle,
                node_id,
                ..
            } => {
                info!("established outgoing connection");

                if let Some(Outgoing{
                    state: OutgoingState::Blocked { .. }, ..
                }) = self.outgoing.get(&addr) {
                    // If we connected to a blocked address, do not go into connected, but stay
                    // blocked instead.
                    Some(DialRequest::Disconnect{
                        handle, span
                    })
                } else {
                    // Otherwise, just record the connected state.
                    self.change_outgoing_state(
                        addr,
                        OutgoingState::Connected {
                            peer_id: node_id,
                            handle,
                        },
                    );
                    None
                }
            }

            DialOutcome::Failed { addr, error, when } => {
                info!(err = display_error(&error), "outgoing connection failed");

                if let Some(outgoing) = self.outgoing.get(&addr) {
                    match outgoing.state {
                        OutgoingState::Connecting { failures_so_far,.. } => {
                            self.change_outgoing_state(
                                addr,
                                OutgoingState::Waiting {
                                    failures_so_far: failures_so_far + 1,
                                    error: Some(error),
                                    last_failure: when,
                                },
                            );
                            None
                        }
                        OutgoingState::Blocked { .. } => {
                            debug!("failed dial outcome after block ignored");

                            // We do not set the connection to "waiting" if an out-of-order failed
                            // connection arrives, but continue to honor the blocking.
                            None
                        }
                        OutgoingState::Waiting { .. } |
                        OutgoingState::Connected { .. } |
                        OutgoingState::Loopback => {
                            warn!(
                                "processing dial outcome on a connection that was not marked as connecting or blocked"
                            );

                            None
                        }
                    }
                } else {
                    warn!("processing dial outcome non-existent connection");

                    // If the connection does not exist, do not introduce it!
                    None
                }
            }
            DialOutcome::Loopback { addr } => {
                info!("found loopback address");
                self.change_outgoing_state(addr, OutgoingState::Loopback);
                None
            }
        })
    }
/// Handles the outcome of a dialing attempt.
///
/// Note that reconnects will earliest happen on the next `perform_housekeeping` call.
Handles the outcome of a dialing attempt.
Note that reconnects will earliest happen on the next `perform_housekeeping` call.
Handles the outcome of a dialing attempt . Note that reconnects will earliest happen on the next ` perform_housekeeping ` call .
pub(crate) fn handle_dial_outcome(
        &mut self,
        dial_outcome: DialOutcome<H, E>,
    ) -> Option<DialRequest<H>> {
        let addr = dial_outcome.addr();
        let span = make_span(addr, self.outgoing.get(&addr));
        span.clone().in_scope(move || match dial_outcome {
            DialOutcome::Successful {
                addr,
                handle,
                node_id,
                ..
            } => {
                info!("established outgoing connection");
                if let Some(Outgoing{
                    state: OutgoingState::Blocked { .. }, ..
                }) = self.outgoing.get(&addr) {
                    // If we connected to a blocked address, do not go into connected, but stay
                    // blocked instead.
                    Some(DialRequest::Disconnect{
                        handle, span
                    })
                } else {
                    // Otherwise, just record the connected state.
                    self.change_outgoing_state(
                        addr,
                        OutgoingState::Connected {
                            peer_id: node_id,
                            handle,
                        },
                    );
                    None
                }
            }
            DialOutcome::Failed { addr, error, when } => {
                info!(err = display_error(&error), "outgoing connection failed");
                if let Some(outgoing) = self.outgoing.get(&addr) {
                    match outgoing.state {
                        OutgoingState::Connecting { failures_so_far,.. } => {
                            self.change_outgoing_state(
                                addr,
                                OutgoingState::Waiting {
                                    failures_so_far: failures_so_far + 1,
                                    error: Some(error),
                                    last_failure: when,
                                },
                            );
                            None
                        }
                        OutgoingState::Blocked { .. } => {
                            debug!("failed dial outcome after block ignored");
                            // We do not set the connection to "waiting" if an out-of-order failed
                            // connection arrives, but continue to honor the blocking.
                            None
                        }
                        OutgoingState::Waiting { .. } |
                        OutgoingState::Connected { .. } |
                        OutgoingState::Loopback => {
                            warn!(
                                "processing dial outcome on a connection that was not marked as connecting or blocked"
                            );
                            None
                        }
                    }
                } else {
                    warn!("processing dial outcome non-existent connection");
                    // If the connection does not exist, do not introduce it!
                    None
                }
            }
            DialOutcome::Loopback { addr } => {
                info!("found loopback address");
                self.change_outgoing_state(addr, OutgoingState::Loopback);
                None
            }
        })
    }
pub ( crate ) fn handle_dial_outcome ( & mut self , dial_outcome : DialOutcome < H , E > , ) -> Option < DialRequest < H > > { let addr = dial_outcome . addr ( ) ; let span = make_span ( addr , self . outgoing . get ( & addr ) ) ; span . clone ( ) . in_scope ( move | | match dial_outcome { DialOutcome :: Successful { addr , handle , node_id , .. } => { info ! ( " " ) ; if let Some ( Outgoing { state : OutgoingState :: Blocked { .. } , .. } ) = self . outgoing . get ( & addr ) { // If we connected to a blocked address, do not go into connected, but stay // blocked instead. Some ( DialRequest :: Disconnect { handle , span } ) } else { // Otherwise, just record the connected state. self . change_outgoing_state ( addr , OutgoingState :: Connected { peer_id : node_id , handle , } , ) ; None } } DialOutcome :: Failed { addr , error , when } => { info ! ( err display_error ( error ) " " ) ; if let Some ( outgoing ) = self . outgoing . get ( & addr ) { match outgoing . state { OutgoingState :: Connecting { failures_so_far , .. } => { self . change_outgoing_state ( addr , OutgoingState :: Waiting { failures_so_far : failures_so_far + 1 , error : Some ( error ) , last_failure : when , } , ) ; None } OutgoingState :: Blocked { .. } => { debug ! ( " " ) ; // We do not set the connection to "waiting" if an out-of-order failed // connection arrives, but continue to honor the blocking. None } OutgoingState :: Waiting { .. } | OutgoingState :: Connected { .. } | OutgoingState :: Loopback => { warn ! ( " " ) ; None } } } else { warn ! ( " " ) ; // If the connection does not exist, do not introduce it! None } } DialOutcome :: Loopback { addr } => { info ! ( " " ) ; self . change_outgoing_state ( addr , OutgoingState :: Loopback ) ; None } } ) }
Handles the outcome of a dialing attempt.
Handles the outcome of a dialing attempt .
&mut self
dial_outcome
DialOutcome<H, E>
&mut self
dial_outcome
DialOutcome<H, E>