pub fn status(&self) -> NodeStatus {
        let curr_time = Instant::now();

        // Check if node has ever responded to us
        let since_response = match self.last_response {
            Some(response_time) => curr_time - response_time,
            None => return NodeStatus::Bad,
        };

        // Check if node has recently responded to us
        if since_response < Duration::from_secs(MAX_LAST_SEEN_MINS * 60) {
            return NodeStatus::Good;
        }

        // Check if we have request from node multiple times already without response
        if self.refresh_requests >= MAX_REFRESH_REQUESTS {
            return NodeStatus::Bad;
        }

        // Check if the node has recently requested from us
        if let Some(request_time) = self.last_request {
            let since_request = curr_time - request_time;

            if since_request < Duration::from_secs(MAX_LAST_SEEN_MINS * 60) {
                return NodeStatus::Good;
            }
        }

        NodeStatus::Questionable
    }
/// Current status of the node.
///
/// The specification says:
///
/// https://www.bittorrent.org/beps/bep_0005.html
///
/// A good node is a node has responded to one of our queries within the last 15 minutes. A node is also good
/// if it has ever responded to one of our queries and has sent us a query within the last 15 minutes.
/// After 15 minutes of inactivity, a node becomes questionable. Nodes become bad when they fail to respond to
/// multiple queries in a row.
Current status of the node.
The specification says.



A good node is a node has responded to one of our queries within the last 15 minutes. A node is also good
if it has ever responded to one of our queries and has sent us a query within the last 15 minutes.
After 15 minutes of inactivity, a node becomes questionable. Nodes become bad when they fail to respond to
multiple queries in a row.
Current status of the node . The specification says . A good node is a node has responded to one of our queries within the last 15 minutes . A node is also good if it has ever responded to one of our queries and has sent us a query within the last 15 minutes . After 15 minutes of inactivity a node becomes questionable . Nodes become bad when they fail to respond to multiple queries in a row .
pub fn status(&self) -> NodeStatus {
        let curr_time = Instant::now();
        // Check if node has ever responded to us
        let since_response = match self.last_response {
            Some(response_time) => curr_time - response_time,
            None => return NodeStatus::Bad,
        };
        // Check if node has recently responded to us
        if since_response < Duration::from_secs(MAX_LAST_SEEN_MINS * 60) {
            return NodeStatus::Good;
        }
        // Check if we have request from node multiple times already without response
        if self.refresh_requests >= MAX_REFRESH_REQUESTS {
            return NodeStatus::Bad;
        }
        // Check if the node has recently requested from us
        if let Some(request_time) = self.last_request {
            let since_request = curr_time - request_time;
            if since_request < Duration::from_secs(MAX_LAST_SEEN_MINS * 60) {
                return NodeStatus::Good;
            }
        }
        NodeStatus::Questionable
    }
pub fn status ( & self ) -> NodeStatus { let curr_time = Instant :: now ( ) ; // Check if node has ever responded to us let since_response = match self . last_response { Some ( response_time ) => curr_time - response_time , None => return NodeStatus :: Bad , } ; // Check if node has recently responded to us if since_response < Duration :: from_secs ( MAX_LAST_SEEN_MINS * 60 ) { return NodeStatus :: Good ; } // Check if we have request from node multiple times already without response if self . refresh_requests >= MAX_REFRESH_REQUESTS { return NodeStatus :: Bad ; } // Check if the node has recently requested from us if let Some ( request_time ) = self . last_request { let since_request = curr_time - request_time ; if since_request < Duration :: from_secs ( MAX_LAST_SEEN_MINS * 60 ) { return NodeStatus :: Good ; } } NodeStatus :: Questionable }
Current status of the node.
Current status of the node .
&self
&self