node: use method to access session's Node ID
Make accessing an important session value, the Node ID, as a method to Session. Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
parent
6f3a598cc1
commit
25c982cd8c
|
|
@ -1126,13 +1126,7 @@ impl Sessions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn by_id(&self, id: &NodeId) -> Option<&Session> {
|
pub fn by_id(&self, id: &NodeId) -> Option<&Session> {
|
||||||
self.0.values().find(|p| {
|
self.0.values().find(|p| p.node_id() == Some(*id))
|
||||||
if let session::State::Negotiated { id: _id, .. } = &p.state {
|
|
||||||
_id == id
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterator over fully negotiated peers.
|
/// Iterator over fully negotiated peers.
|
||||||
|
|
|
||||||
|
|
@ -122,4 +122,11 @@ impl Session {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn node_id(&self) -> Option<NodeId> {
|
||||||
|
if let State::Negotiated { id, .. } = &self.state {
|
||||||
|
return Some(*id);
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue