Whitespacey lines are not invalid in reserved peers file.

Fixes #1622
This commit is contained in:
Gav Wood 2016-07-29 10:22:51 +02:00
parent 360ed1a1f1
commit a44ef73b33

View File

@ -350,11 +350,11 @@ impl Configuration {
let mut buffer = String::new(); let mut buffer = String::new();
let mut node_file = try!(File::open(path).map_err(|e| format!("Error opening reserved nodes file: {}", e))); let mut node_file = try!(File::open(path).map_err(|e| format!("Error opening reserved nodes file: {}", e)));
try!(node_file.read_to_string(&mut buffer).map_err(|_| "Error reading reserved node file")); try!(node_file.read_to_string(&mut buffer).map_err(|_| "Error reading reserved node file"));
if let Some(invalid) = buffer.lines().find(|s| !is_valid_node_url(s)) { let lines = buffer.lines().map(|s| s.trim().to_owned()).filter(|s| s.len() > 0).collect::<Vec<_>>();
Err(format!("Invalid node address format given for a boot node: {}", invalid)) if let Some(invalid) = lines.iter().find(|s| !is_valid_node_url(s)) {
} else { return Err(format!("Invalid node address format given for a boot node: {}", invalid));
Ok(buffer.lines().map(|s| s.to_owned()).collect())
} }
Ok(lines)
}, },
None => Ok(Vec::new()) None => Ok(Vec::new())
} }