Skip to content

Commit

Permalink
refactor code (#2990)
Browse files Browse the repository at this point in the history
refactor: refactor code.
  • Loading branch information
spartucus authored and quentinlesceller committed Sep 4, 2019
1 parent b291467 commit 7aa2765
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions core/src/core/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,7 @@ mod test {

let input = Input {
features: OutputFeatures::Plain,
commit: commit,
commit,
};

let block_hash =
Expand All @@ -1696,7 +1696,7 @@ mod test {
// different) and check it generates a different short_id
let input = Input {
features: OutputFeatures::Coinbase,
commit: commit,
commit,
};

let short_id = input.short_id(&block_hash, nonce);
Expand Down
2 changes: 1 addition & 1 deletion core/src/libtx/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ where
(
tx.with_output(Output {
features: OutputFeatures::Plain,
commit: commit,
commit,
proof: rproof,
}),
kern,
Expand Down
2 changes: 1 addition & 1 deletion core/src/libtx/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl From<ErrorKind> for Error {

impl From<Context<ErrorKind>> for Error {
fn from(inner: Context<ErrorKind>) -> Error {
Error { inner: inner }
Error { inner }
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/libtx/reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ where

let output = Output {
features: OutputFeatures::Coinbase,
commit: commit,
commit,
proof: rproof,
};

Expand Down Expand Up @@ -81,7 +81,7 @@ where

let proof = TxKernel {
features: KernelFeatures::Coinbase,
excess: excess,
excess,
excess_sig: sig,
};
Ok((output, proof))
Expand Down
4 changes: 2 additions & 2 deletions util/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ fn copy_to(src: &Path, src_type: &fs::FileType, dst: &Path) -> io::Result<u64> {
} else if src_type.is_dir() {
copy_dir_to(src, dst)
} else {
return Err(io::Error::new(
Err(io::Error::new(
io::ErrorKind::Other,
format!("Could not copy: {}", src.display()),
));
))
}
}

Expand Down
2 changes: 1 addition & 1 deletion util/src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn from_hex(hex_str: String) -> Result<Vec<u8>, num::ParseIntError> {
}

fn split_n(s: &str, n: usize) -> Vec<&str> {
(0..(s.len() - n + 1) / 2 + 1)
(0..=(s.len() - n + 1) / 2)
.map(|i| &s[2 * i..2 * i + n])
.collect()
}
Expand Down
9 changes: 4 additions & 5 deletions util/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,13 @@ pub fn init_logger(config: Option<LoggingConfig>) {

let level_stdout = convert_log_level(&c.stdout_log_level);
let level_file = convert_log_level(&c.file_log_level);
let level_minimum;

// Determine minimum logging level for Root logger
if level_stdout > level_file {
level_minimum = level_stdout;
let level_minimum = if level_stdout > level_file {
level_stdout
} else {
level_minimum = level_file;
}
level_file
};

// Start logger
let stdout = ConsoleAppender::builder()
Expand Down
4 changes: 2 additions & 2 deletions util/src/rate_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl RateCounter {

fn truncate(&mut self) {
let now_millis = millis_since_epoch();
while self.last_min_entries.len() > 0
while !self.last_min_entries.is_empty()
&& self.last_min_entries[0].timestamp + 60000 < now_millis
{
self.last_min_entries.remove(0);
Expand Down Expand Up @@ -106,5 +106,5 @@ fn millis_since_epoch() -> u64 {
let since_epoch = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap_or(Duration::new(0, 0));
since_epoch.as_secs() * 1000 + since_epoch.subsec_millis() as u64
since_epoch.as_secs() * 1000 + u64::from(since_epoch.subsec_millis())
}

0 comments on commit 7aa2765

Please sign in to comment.