diff options
Diffstat (limited to 'src/peering')
-rw-r--r-- | src/peering/fullmesh.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs index c521590..ea753e1 100644 --- a/src/peering/fullmesh.rs +++ b/src/peering/fullmesh.rs @@ -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, |