Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor code #2990

Merged
merged 2 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/core/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ mod test {

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

let block_hash =
Expand All @@ -1604,7 +1604,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 @@ -49,7 +49,7 @@ where

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

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

let proof = TxKernel {
features: KernelFeatures::Coinbase,
excess: excess,
excess,
excess_sig: sig,
fee: 0,
// lock_height here is 0
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())
}