mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 15:21:05 +00:00
Fix reliance on non-empty NodeInfo::endpoints (#8684)
* Use as_deref instead of .map in Node::client_version * Fix reliance on non-empty NodeInfo::endpoints
This commit is contained in:
committed by
GitHub
parent
06670046bc
commit
be1dce5618
@@ -138,13 +138,15 @@ pub struct Node<'a>(&'a NodeInfo);
|
||||
|
||||
impl<'a> Node<'a> {
|
||||
/// Returns the endpoint of an established connection to the peer.
|
||||
pub fn endpoint(&self) -> &'a ConnectedPoint {
|
||||
&self.0.endpoints[0] // `endpoints` are non-empty by definition
|
||||
///
|
||||
/// Returns `None` if we are disconnected from the node.
|
||||
pub fn endpoint(&self) -> Option<&'a ConnectedPoint> {
|
||||
self.0.endpoints.get(0)
|
||||
}
|
||||
|
||||
/// Returns the latest version information we know of.
|
||||
pub fn client_version(&self) -> Option<&'a str> {
|
||||
self.0.client_version.as_ref().map(|s| &s[..])
|
||||
self.0.client_version.as_deref()
|
||||
}
|
||||
|
||||
/// Returns the latest ping time we know of for this node. `None` if we never successfully
|
||||
|
||||
Reference in New Issue
Block a user