MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / parse_seed_nodes

Function parse_seed_nodes

nodedb/src/config/server/env.rs:403–420  ·  view source on GitHub ↗

Parse a comma-separated list of `SocketAddr` strings. Returns `Ok(Vec )` if every entry parses successfully. Returns `Err(bad_entry)` with the first entry that fails to parse, so callers can log it and skip the entire override.

(s: &str)

Source from the content-addressed store, hash-verified

401/// Returns `Err(bad_entry)` with the first entry that fails to parse,
402/// so callers can log it and skip the entire override.
403pub fn parse_seed_nodes(s: &str) -> crate::Result<Vec<SocketAddr>> {
404 let mut addrs = Vec::new();
405 for entry in s.split(',') {
406 let entry = entry.trim();
407 if entry.is_empty() {
408 continue;
409 }
410 match entry.parse::<SocketAddr>() {
411 Ok(addr) => addrs.push(addr),
412 Err(_) => {
413 return Err(crate::Error::Config {
414 detail: format!("invalid socket address: '{entry}'"),
415 });
416 }
417 }
418 }
419 Ok(addrs)
420}
421
422#[cfg(test)]
423mod tests {

Callers 1

apply_env_overridesFunction · 0.85

Calls 2

is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected