Add .is_up() on connection state
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fe16ff25e9
commit
fba49cf93d
1 changed files with 14 additions and 0 deletions
|
@ -74,6 +74,13 @@ pub struct PeerInfo {
|
||||||
pub med_ping: Option<Duration>,
|
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
|
/// PeerConnState: possible states for our tentative connections to given peer
|
||||||
/// This structure is only interested in recording connection info for outgoing
|
/// This structure is only interested in recording connection info for outgoing
|
||||||
/// TCP connections
|
/// TCP connections
|
||||||
|
@ -96,6 +103,13 @@ pub enum PeerConnState {
|
||||||
Abandonned,
|
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 {
|
struct KnownHosts {
|
||||||
list: HashMap<NodeID, PeerInfoInternal>,
|
list: HashMap<NodeID, PeerInfoInternal>,
|
||||||
hash: hash::Digest,
|
hash: hash::Digest,
|
||||||
|
|
Loading…
Reference in a new issue