Skip to content

Commit

Permalink
feat(cli): allow multiple trusted peers
Browse files Browse the repository at this point in the history
  • Loading branch information
hack3r-0m committed Sep 15, 2023
1 parent a572c3b commit 51f6045
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bin/reth/src/args/network_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct NetworkArgs {

/// Target trusted peer enodes
/// --trusted-peers enode://abcd@192.168.0.1:30303
#[arg(long)]
#[arg(long, value_delimiter = ',')]
pub trusted_peers: Vec<NodeRecord>,

/// Connect only to trusted peers
Expand Down Expand Up @@ -194,4 +194,23 @@ mod tests {
assert_eq!(args.max_outbound_peers, Some(75));
assert_eq!(args.max_inbound_peers, Some(15));
}

#[test]
fn parse_trusted_peer_args() {
let args =
CommandParser::<NetworkArgs>::parse_from([
"reth",
"--trusted-peers",
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303,enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303"
])
.args;

assert_eq!(
args.trusted_peers,
vec![
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303".parse().unwrap(),
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303".parse().unwrap()
]
);
}
}

0 comments on commit 51f6045

Please sign in to comment.