Add .is_up() on connection state
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alex 2021-10-14 14:13:44 +02:00
parent fe16ff25e9
commit fba49cf93d
No known key found for this signature in database
GPG key ID: EDABF9711E244EB1

View file

@ -74,6 +74,13 @@ pub struct PeerInfo {
pub med_ping: Option<Duration>,
}
impl PeerInfo {
/// Returns true if we can currently send requests to this peer
pub fn is_up(&self) -> bool {
self.state.is_up()
}
}
/// PeerConnState: possible states for our tentative connections to given peer
/// This structure is only interested in recording connection info for outgoing
/// TCP connections
@ -96,6 +103,13 @@ pub enum PeerConnState {
Abandonned,
}
impl PeerConnState {
/// Returns true if we can currently send requests to this peer
pub fn is_up(&self) -> bool {
matches!(self, Self::Ourself | Self::Connected)
}
}
struct KnownHosts {
list: HashMap<NodeID, PeerInfoInternal>,
hash: hash::Digest,