Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: use method to access session's Node ID
Slack Coder committed 3 years ago
commit 25c982cd8c06ef1df0b785d7684bca7651d0bba8
parent 6f3a598cc168479394b9e88c60ecd427f099f91b
2 files changed +8 -7
modified radicle-node/src/service.rs
@@ -1126,13 +1126,7 @@ impl Sessions {
    }

    pub fn by_id(&self, id: &NodeId) -> Option<&Session> {
-
        self.0.values().find(|p| {
-
            if let session::State::Negotiated { id: _id, .. } = &p.state {
-
                _id == id
-
            } else {
-
                false
-
            }
-
        })
+
        self.0.values().find(|p| p.node_id() == Some(*id))
    }

    /// Iterator over fully negotiated peers.
modified radicle-node/src/service/session.rs
@@ -122,4 +122,11 @@ impl Session {
        }
        Ok(())
    }
+

+
    pub fn node_id(&self) -> Option<NodeId> {
+
        if let State::Negotiated { id, .. } = &self.state {
+
            return Some(*id);
+
        }
+
        None
+
    }
}