pub fn received_timeout<T: BlockTree>(&mut self, local_time: LocalTime, tree: &T) {
        let timeout = self.config.request_timeout;
        let timed_out = self
            .inflight
            .iter()
            .filter_map(|(peer, req)| {
                if local_time - req.sent_at >= timeout {
                    Some((*peer, req.on_timeout))
                } else {
                    None
                }
            })
            .collect::<Vec<_>>();

        for (peer, on_timeout) in &timed_out {
            self.inflight.remove(&peer);

            match on_timeout {
                OnTimeout::Disconnect => {
                    self.unregister(&peer);
                    self.upstream
                        .disconnect(*peer, DisconnectReason::PeerTimeout("sync"));
                }
                OnTimeout::Ignore => {
                    // It's likely that the peer just didn't have the requested header.
                }
            }
            self.upstream.event(Event::TimedOut(*peer));
        }

        // If some of the requests timed out, force a sync, otherwise just idle.
        if timed_out.is_empty() {
            self.idle(local_time, tree);
        } else {
            self.sync(local_time, tree);
        }
    }
/// Called when we received a timeout.
Called when we received a timeout.
Called when we received a timeout .
pub fn received_timeout<T: BlockTree>(&mut self, local_time: LocalTime, tree: &T) {
        let timeout = self.config.request_timeout;
        let timed_out = self
            .inflight
            .iter()
            .filter_map(|(peer, req)| {
                if local_time - req.sent_at >= timeout {
                    Some((*peer, req.on_timeout))
                } else {
                    None
                }
            })
            .collect::<Vec<_>>();
        for (peer, on_timeout) in &timed_out {
            self.inflight.remove(&peer);
            match on_timeout {
                OnTimeout::Disconnect => {
                    self.unregister(&peer);
                    self.upstream
                        .disconnect(*peer, DisconnectReason::PeerTimeout("sync"));
                }
                OnTimeout::Ignore => {
                    // It's likely that the peer just didn't have the requested header.
                }
            }
            self.upstream.event(Event::TimedOut(*peer));
        }
        // If some of the requests timed out, force a sync, otherwise just idle.
        if timed_out.is_empty() {
            self.idle(local_time, tree);
        } else {
            self.sync(local_time, tree);
        }
    }
pub fn received_timeout < T : BlockTree > ( & mut self , local_time : LocalTime , tree : & T ) { let timeout = self . config . request_timeout ; let timed_out = self . inflight . iter ( ) . filter_map ( | ( peer , req ) | { if local_time - req . sent_at >= timeout { Some ( ( * peer , req . on_timeout ) ) } else { None } } ) . collect :: < Vec < _ > > ( ) ; for ( peer , on_timeout ) in & timed_out { self . inflight . remove ( & peer ) ; match on_timeout { OnTimeout :: Disconnect => { self . unregister ( & peer ) ; self . upstream . disconnect ( * peer , DisconnectReason :: PeerTimeout ( " " ) ) ; } OnTimeout :: Ignore => { // It's likely that the peer just didn't have the requested header. } } self . upstream . event ( Event :: TimedOut ( * peer ) ) ; } // If some of the requests timed out, force a sync, otherwise just idle. if timed_out . is_empty ( ) { self . idle ( local_time , tree ) ; } else { self . sync ( local_time , tree ) ; } }
Called when we received a timeout.
Called when we received a timeout .
&mut self
local_time
LocalTime
tree
&T