Skip to content

Commit

Permalink
remove double flag
Browse files Browse the repository at this point in the history
  • Loading branch information
divagant-martian committed May 29, 2023
1 parent e611365 commit 4880119
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
17 changes: 5 additions & 12 deletions beacon_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,6 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.help("Lighthouse by default does not discover private IP addresses. Set this flag to enable connection attempts to local addresses.")
.takes_value(false),
)
.arg(
Arg::with_name("disable-inbound-rate-limiter")
.long("disable-inbound-rate-limiter")
.help("Disables the inbound rate limiting (received by this node) over rpc. \
Note: using this option could overwhelm the node with unbounded number \
of rpc requests. Use with caution.")
.hidden(true)
.takes_value(false),
)
.arg(
Arg::with_name("self-limiter")
.long("self-limiter")
Expand Down Expand Up @@ -295,14 +286,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
Arg::with_name("inbound-rate-limiter")
.long("inbound-rate-limiter")
.help(
"Enables the inbound rate limiter (requests received by this node).\
"Configures the inbound rate limiter (requests received by this node).\
\
Rate limit quotas per protocol can be set in the form of \
<protocol_name>:<tokens>/<time_in_seconds>. To set quotas for multiple protocols, \
separate them by ';'. If the inbound rate limiter is enabled and a protocol is not \
present in the configuration, the default quotas will be used."
present in the configuration, the default quotas will be used. \
\
This is enabled by default, using default quotas. To disable rate limiting pass \
`disabled` to this option instead."
)
.min_values(0)
.hidden(true)
)
.arg(
Expand Down
30 changes: 17 additions & 13 deletions beacon_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,18 +1253,22 @@ pub fn set_network_config(
config.proposer_only = true;
warn!(log, "Proposer-only mode enabled"; "info"=> "Do not connect a validator client to this node unless via the --proposer-nodes flag");
}
// The inbound rate limiter is enabled by default unless the `disable-inbound-rate-limiter` flag is specified.
// Hence, we first try to parse it with a value, if no value is defined, we set it to the default parameters.
// If `disable-inbound-rate-limiter` is specified, we disable inbound rate limiting explicitly.
config.inbound_rate_limiter_config =
clap_utils::parse_optional(cli_args, "inbound-rate-limiter")?;
if config.inbound_rate_limiter_config.is_none() {
config.inbound_rate_limiter_config = Some(Default::default());
}
if cli_args.is_present("disable-inbound-rate-limiter") {
config.inbound_rate_limiter_config = None;
}

// The inbound rate limiter is enabled by default unless `disabled` is passed to the
// `inbound-rate-limiter` flag. Any other value should be parsed as a configuration string.
config.inbound_rate_limiter_config = match cli_args.value_of("inbound-rate-limiter") {
None => {
// Enabled by default, with default values
Some(Default::default())
}
Some("disabled") => {
// Explicitly disabled
None
}
Some(config_str) => {
// Enabled with a custom configuration
Some(config_str.parse()?)
}
};
Ok(())
}

Expand Down Expand Up @@ -1340,4 +1344,4 @@ where
.into_iter()
.next()
.ok_or(format!("Must provide at least one value to {}", flag_name))
}
}

0 comments on commit 4880119

Please sign in to comment.