Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Mar 27, 2018
1 parent 25af5b5 commit 9d421ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions parity/cli/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,16 @@ macro_rules! usage {
pub fn parse<S: AsRef<str>>(command: &[S]) -> Result<Self, ArgsError> {
let raw_args = RawArgs::parse(command)?;

// Invalid configuration pattern `mix_peers` > `max_peers`
if let (Some(max_peers), Some(min_peers)) = (raw_args.arg_max_peers, raw_args.arg_min_peers) {
// Invalid configuration pattern `mix_peers` > `max_peers`
if min_peers > max_peers {
return Err(ArgsError::PeerConfiguration)
return Err(ArgsError::PeerConfiguration);
}
}
}

// Skip loading config file if no_config flag is specified
else if raw_args.flag_no_config {
return Ok(raw_args.into_args(Config::default()))
if raw_args.flag_no_config {
return Ok(raw_args.into_args(Config::default()));
}

let config_file = raw_args.arg_config.clone().unwrap_or_else(|| raw_args.clone().into_args(Config::default()).arg_config);
Expand Down
5 changes: 3 additions & 2 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use std::cmp::{max, min};
use std::time::Duration;
use std::io::Read;
use std::net::SocketAddr;
Expand Down Expand Up @@ -471,7 +472,7 @@ impl Configuration {

fn max_peers(&self) -> u32 {
self.args.arg_max_peers
.or(self.args.arg_min_peers)
.or(max(self.args.arg_min_peers, Some(DEFAULT_MAX_PEERS)))
.unwrap_or(DEFAULT_MAX_PEERS) as u32
}

Expand All @@ -484,7 +485,7 @@ impl Configuration {

fn min_peers(&self) -> u32 {
self.args.arg_min_peers
.or(self.args.arg_max_peers)
.or(min(self.args.arg_max_peers, Some(DEFAULT_MIN_PEERS)))
.unwrap_or(DEFAULT_MIN_PEERS) as u32
}

Expand Down

0 comments on commit 9d421ab

Please sign in to comment.