Skip to content

Commit

Permalink
feat(cli): allow multiple trusted peers (#4619)
Browse files Browse the repository at this point in the history
  • Loading branch information
hack3r-0m authored Sep 15, 2023
1 parent 357301c commit 62e7d98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
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()
]
);
}
}
2 changes: 1 addition & 1 deletion book/cli/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Networking:
The UDP port to use for P2P discovery/networking. default: 30303

--trusted-peers <TRUSTED_PEERS>
Target trusted peer enodes --trusted-peers enode://abcd@192.168.0.1:30303
Target trusted peer enodes --trusted-peers enode://abcd@192.168.0.1:30303,enode://cdef@192.168.0.2:30303

--trusted-only
Connect only to trusted peers
Expand Down

0 comments on commit 62e7d98

Please sign in to comment.