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

Commit

Permalink
simplify code according to the review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Mar 27, 2018
1 parent 044b329 commit 25af5b5
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,9 @@ impl Configuration {
}

fn max_peers(&self) -> u32 {
match (self.args.arg_max_peers, self.args.arg_min_peers) {
// Only `min_peers` specified by the user then set `max_peers` to that value
(None, Some(min)) => min as u32,

// Both or none specified by the user and max ensured to be bigger than min
(_, _) => self.args.arg_max_peers.unwrap_or(DEFAULT_MAX_PEERS) as u32,
}
self.args.arg_max_peers
.or(self.args.arg_min_peers)
.unwrap_or(DEFAULT_MAX_PEERS) as u32
}

fn ip_filter(&self) -> Result<IpFilter, String> {
Expand All @@ -487,13 +483,9 @@ impl Configuration {
}

fn min_peers(&self) -> u32 {
match (self.args.arg_max_peers, self.args.arg_min_peers) {
// Only `max_peers` specified by the user then set `min_peers` to that value
(Some(max), None) => max as u32,

// Both or none specified by the user and max ensured to be bigger than min
(_, _) => self.args.arg_min_peers.unwrap_or(DEFAULT_MIN_PEERS) as u32,
}
self.args.arg_min_peers
.or(self.args.arg_max_peers)
.unwrap_or(DEFAULT_MIN_PEERS) as u32
}

fn max_pending_peers(&self) -> u32 {
Expand Down

0 comments on commit 25af5b5

Please sign in to comment.