aboutsummaryrefslogtreecommitdiff
path: root/src/peering/fullmesh.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-14 14:13:44 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-14 14:13:44 +0200
commitfba49cf93dedae21cbe884db8c0124c0d3c88730 (patch)
tree981136ef15dec999023c31d271130baac61d1c68 /src/peering/fullmesh.rs
parentfe16ff25e961e4d40e2641c1247e3b6c3c09e966 (diff)
downloadnetapp-fba49cf93dedae21cbe884db8c0124c0d3c88730.tar.gz
netapp-fba49cf93dedae21cbe884db8c0124c0d3c88730.zip
Add .is_up() on connection state
Diffstat (limited to 'src/peering/fullmesh.rs')
-rw-r--r--src/peering/fullmesh.rs14
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,