Added is_valid_node_url
This commit is contained in:
parent
85c842b7fd
commit
beab90c707
@ -89,6 +89,7 @@ pub use network::host::NetworkConfiguration;
|
|||||||
pub use network::stats::NetworkStats;
|
pub use network::stats::NetworkStats;
|
||||||
|
|
||||||
use io::TimerToken;
|
use io::TimerToken;
|
||||||
|
pub use network::node_table::is_valid_node_url;
|
||||||
|
|
||||||
const PROTOCOL_VERSION: u32 = 4;
|
const PROTOCOL_VERSION: u32 = 4;
|
||||||
|
|
||||||
|
@ -332,6 +332,11 @@ impl Drop for NodeTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_valid_node_url(url: &str) -> bool {
|
||||||
|
use std::str::FromStr;
|
||||||
|
Node::from_str(url).is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -353,6 +358,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn node_parse() {
|
fn node_parse() {
|
||||||
|
assert!(is_valid_node_url("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770"));
|
||||||
let node = Node::from_str("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770");
|
let node = Node::from_str("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770");
|
||||||
assert!(node.is_ok());
|
assert!(node.is_ok());
|
||||||
let node = node.unwrap();
|
let node = node.unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user