pub fn check<T, F>(
        &mut self,
        now: Instant,
        node: (Pubkey, SocketAddr),
        pingf: F,
    ) -> (bool, Option<Ping<T>>)
    where
        T: Serialize,
        F: FnMut() -> Option<Ping<T>>,
    {
        let (check, should_ping) = match self.pongs.get(&node) {
            None => (false, true),
            Some(t) => {
                let age = now.saturating_duration_since(*t);
                // Pop if the pong message has expired.
                if age > self.ttl {
                    self.pongs.pop(&node);
                }
                // If the pong message is not too recent, generate a new ping
                // message to extend remote node verification.
                (true, age > self.ttl / 8)
            }
        };
        let ping = if should_ping {
            self.maybe_ping(now, node, pingf)
        } else {
            None
        };
        (check, ping)
    }
/// Returns true if the remote node has responded to a ping message.
/// Removes expired pong messages. In order to extend verifications before
/// expiration, if the pong message is not too recent, and the node has not
/// been pinged recently, calls the given function to generates a new ping
/// message, records current timestamp and hash of ping token, and returns
/// the ping message.
/// Caller should verify if the socket address is valid. (e.g. by using
/// ContactInfo::is_valid_address).
Returns true if the remote node has responded to a ping message.
Removes expired pong messages. In order to extend verifications before
expiration, if the pong message is not too recent, and the node has not
been pinged recently, calls the given function to generates a new ping
message, records current timestamp and hash of ping token, and returns
the ping message.
Caller should verify if the socket address is valid.
Returns true if the remote node has responded to a ping message . Removes expired pong messages . In order to extend verifications before expiration if the pong message is not too recent and the node has not been pinged recently calls the given function to generates a new ping message records current timestamp and hash of ping token and returns the ping message . Caller should verify if the socket address is valid .
pub fn check<T, F>(
        &mut self,
        now: Instant,
        node: (Pubkey, SocketAddr),
        pingf: F,
    ) -> (bool, Option<Ping<T>>)
    where
        T: Serialize,
        F: FnMut() -> Option<Ping<T>>,
    {
        let (check, should_ping) = match self.pongs.get(&node) {
            None => (false, true),
            Some(t) => {
                let age = now.saturating_duration_since(*t);
                // Pop if the pong message has expired.
                if age > self.ttl {
                    self.pongs.pop(&node);
                }
                // If the pong message is not too recent, generate a new ping
                // message to extend remote node verification.
                (true, age > self.ttl / 8)
            }
        };
        let ping = if should_ping {
            self.maybe_ping(now, node, pingf)
        } else {
            None
        };
        (check, ping)
    }
pub fn check < T , F > ( & mut self , now : Instant , node : ( Pubkey , SocketAddr ) , pingf : F , ) -> ( bool , Option < Ping < T > > ) where T : Serialize , F : FnMut ( ) -> Option < Ping < T > > , { let ( check , should_ping ) = match self . pongs . get ( & node ) { None => ( false , true ) , Some ( t ) => { let age = now . saturating_duration_since ( * t ) ; // Pop if the pong message has expired. if age > self . ttl { self . pongs . pop ( & node ) ; } // If the pong message is not too recent, generate a new ping // message to extend remote node verification. ( true , age > self . ttl / 8 ) } } ; let ping = if should_ping { self . maybe_ping ( now , node , pingf ) } else { None } ; ( check , ping ) }
Returns true if the remote node has responded to a ping message.
Returns true if the remote node has responded to a ping message .
&mut self
now
Instant
node
(Pubkey, SocketAddr)
pingf
F