mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
clippy says: avoid needless "1 *"
clippy says: make operator precedence explicit
This commit is contained in:
parent
2299a03248
commit
dda8497d54
2 changed files with 5 additions and 5 deletions
|
@ -250,7 +250,7 @@ impl HeaderInfo {
|
||||||
|
|
||||||
/// Move value linearly toward a goal
|
/// Move value linearly toward a goal
|
||||||
pub fn damp(actual: u64, goal: u64, damp_factor: u64) -> u64 {
|
pub fn damp(actual: u64, goal: u64, damp_factor: u64) -> u64 {
|
||||||
(1 * actual + (damp_factor - 1) * goal) / damp_factor
|
(actual + (damp_factor - 1) * goal) / damp_factor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// limit value to be within some factor from a goal
|
/// limit value to be within some factor from a goal
|
||||||
|
|
|
@ -89,7 +89,7 @@ pub fn to_entropy(mnemonic: &str) -> Result<Vec<u8>, Error> {
|
||||||
for index in indexes.iter().rev() {
|
for index in indexes.iter().rev() {
|
||||||
for i in 0..11 {
|
for i in 0..11 {
|
||||||
let bit = index & (1 << i) != 0;
|
let bit = index & (1 << i) != 0;
|
||||||
entropy[datalen - loc / 8] |= (bit as u8) << loc % 8;
|
entropy[datalen - loc / 8] |= (bit as u8) << (loc % 8);
|
||||||
loc += 1;
|
loc += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ pub fn to_entropy(mnemonic: &str) -> Result<Vec<u8>, Error> {
|
||||||
sha2sum.input(&entropy.clone());
|
sha2sum.input(&entropy.clone());
|
||||||
hash.copy_from_slice(sha2sum.result().as_slice());
|
hash.copy_from_slice(sha2sum.result().as_slice());
|
||||||
|
|
||||||
let actual = (hash[0] >> 8 - checksum_bits) & mask;
|
let actual = (hash[0] >> (8 - checksum_bits)) & mask;
|
||||||
|
|
||||||
if actual != checksum {
|
if actual != checksum {
|
||||||
return Err(Error::BadChecksum(checksum, actual));
|
return Err(Error::BadChecksum(checksum, actual));
|
||||||
|
@ -134,13 +134,13 @@ pub fn from_entropy(entropy: &Vec<u8>) -> Result<String, Error> {
|
||||||
for byte in entropy.iter() {
|
for byte in entropy.iter() {
|
||||||
for i in (0..8).rev() {
|
for i in (0..8).rev() {
|
||||||
let bit = byte & (1 << i) != 0;
|
let bit = byte & (1 << i) != 0;
|
||||||
indexes[loc / 11] |= (bit as u16) << 10 - (loc % 11);
|
indexes[loc / 11] |= (bit as u16) << (10 - (loc % 11));
|
||||||
loc += 1;
|
loc += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i in (0..checksum_bits).rev() {
|
for i in (0..checksum_bits).rev() {
|
||||||
let bit = checksum & (1 << i) != 0;
|
let bit = checksum & (1 << i) != 0;
|
||||||
indexes[loc / 11] |= (bit as u16) << 10 - (loc % 11);
|
indexes[loc / 11] |= (bit as u16) << (10 - (loc % 11));
|
||||||
loc += 1;
|
loc += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue