Add .is_up() on connection state
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>,
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue