Skip to content
This repository was archived by the owner on Aug 3, 2020. It is now read-only.

Commit 45c74c1

Browse files
spartucusgaryyu
authored andcommitted
refactor code (mimblewimble#2990)
refactor: refactor code.
1 parent 6781eb9 commit 45c74c1

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

core/src/core/transaction.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ mod test {
17131713

17141714
let input = Input {
17151715
features: OutputFeatures::Plain,
1716-
commit: commit,
1716+
commit,
17171717
};
17181718

17191719
let block_hash =
@@ -1729,7 +1729,7 @@ mod test {
17291729
// different) and check it generates a different short_id
17301730
let input = Input {
17311731
features: OutputFeatures::Coinbase,
1732-
commit: commit,
1732+
commit,
17331733
};
17341734

17351735
let short_id = input.short_id(&block_hash, nonce);

core/src/libtx/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ where
129129
(
130130
tx.with_output(Output {
131131
features: OutputFeatures::Plain,
132-
commit: commit,
132+
commit,
133133
proof: rproof,
134134
}),
135135
kern,

core/src/libtx/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl From<ErrorKind> for Error {
7979

8080
impl From<Context<ErrorKind>> for Error {
8181
fn from(inner: Context<ErrorKind>) -> Error {
82-
Error { inner: inner }
82+
Error { inner }
8383
}
8484
}
8585

core/src/libtx/reward.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ where
4848

4949
let output = Output {
5050
features: OutputFeatures::Coinbase,
51-
commit: commit,
51+
commit,
5252
proof: rproof,
5353
};
5454

@@ -81,7 +81,7 @@ where
8181

8282
let proof = TxKernel {
8383
features: KernelFeatures::Coinbase,
84-
excess: excess,
84+
excess,
8585
excess_sig: sig,
8686
};
8787
Ok((output, proof))

util/src/file.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ fn copy_to(src: &Path, src_type: &fs::FileType, dst: &Path) -> io::Result<u64> {
6161
} else if src_type.is_dir() {
6262
copy_dir_to(src, dst)
6363
} else {
64-
return Err(io::Error::new(
64+
Err(io::Error::new(
6565
io::ErrorKind::Other,
6666
format!("Could not copy: {}", src.display()),
67-
));
67+
))
6868
}
6969
}
7070

util/src/hex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn from_hex(hex_str: String) -> Result<Vec<u8>, num::ParseIntError> {
4949
}
5050

5151
fn split_n(s: &str, n: usize) -> Vec<&str> {
52-
(0..(s.len() - n + 1) / 2 + 1)
52+
(0..=(s.len() - n + 1) / 2)
5353
.map(|i| &s[2 * i..2 * i + n])
5454
.collect()
5555
}

util/src/logger.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,13 @@ pub fn init_logger(config: Option<LoggingConfig>) {
8888

8989
let level_stdout = convert_log_level(&c.stdout_log_level);
9090
let level_file = convert_log_level(&c.file_log_level);
91-
let level_minimum;
9291

9392
// Determine minimum logging level for Root logger
94-
if level_stdout > level_file {
95-
level_minimum = level_stdout;
93+
let level_minimum = if level_stdout > level_file {
94+
level_stdout
9695
} else {
97-
level_minimum = level_file;
98-
}
96+
level_file
97+
};
9998

10099
// Start logger
101100
let stdout = ConsoleAppender::builder()

util/src/rate_counter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl RateCounter {
7777

7878
fn truncate(&mut self) {
7979
let now_millis = millis_since_epoch();
80-
while self.last_min_entries.len() > 0
80+
while !self.last_min_entries.is_empty()
8181
&& self.last_min_entries[0].timestamp + 60000 < now_millis
8282
{
8383
self.last_min_entries.remove(0);
@@ -106,5 +106,5 @@ fn millis_since_epoch() -> u64 {
106106
let since_epoch = SystemTime::now()
107107
.duration_since(SystemTime::UNIX_EPOCH)
108108
.unwrap_or(Duration::new(0, 0));
109-
since_epoch.as_secs() * 1000 + since_epoch.subsec_millis() as u64
109+
since_epoch.as_secs() * 1000 + u64::from(since_epoch.subsec_millis())
110110
}

0 commit comments

Comments
 (0)