mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Fix leading zeroes bugs (#3763)
* remove two unneeded mut's * ensure correct size for leading_zeros()
This commit is contained in:
parent
b69f18d0a2
commit
399fb19c30
7 changed files with 11 additions and 11 deletions
|
@ -161,7 +161,7 @@ impl GlobalConfig {
|
|||
/// apply defaults for each chain type
|
||||
pub fn for_chain(chain_type: &global::ChainTypes) -> GlobalConfig {
|
||||
let mut defaults_conf = GlobalConfig::default();
|
||||
let mut defaults = &mut defaults_conf.members.as_mut().unwrap().server;
|
||||
let defaults = &mut defaults_conf.members.as_mut().unwrap().server;
|
||||
defaults.chain_type = chain_type.clone();
|
||||
|
||||
match *chain_type {
|
||||
|
|
|
@ -70,7 +70,7 @@ impl PoWContext for CuckarooContext {
|
|||
let mut uvs = vec![0u64; 2 * size];
|
||||
let mut xor0: u64 = 0;
|
||||
let mut xor1: u64 = 0;
|
||||
let mask = u64::MAX >> size.leading_zeros(); // round size up to 2-power - 1
|
||||
let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1
|
||||
// the next three arrays form a linked list of nodes with matching bits 6..1
|
||||
let mut headu = vec![2 * size; 1 + mask as usize];
|
||||
let mut headv = vec![2 * size; 1 + mask as usize];
|
||||
|
|
|
@ -65,7 +65,7 @@ impl PoWContext for CuckaroodContext {
|
|||
let mut ndir = vec![0usize; 2];
|
||||
let mut xor0: u64 = 0;
|
||||
let mut xor1: u64 = 0;
|
||||
let mask = u64::MAX >> size.leading_zeros(); // round size up to 2-power - 1
|
||||
let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1
|
||||
// the next two arrays form a linked list of nodes with matching bits 4..0|dir
|
||||
let mut headu = vec![2 * size; 1 + mask as usize];
|
||||
let mut headv = vec![2 * size; 1 + mask as usize];
|
||||
|
|
|
@ -64,7 +64,7 @@ impl PoWContext for CuckaroomContext {
|
|||
let mut to = vec![0u64; size];
|
||||
let mut xor_from: u64 = 0;
|
||||
let mut xor_to: u64 = 0;
|
||||
let mask = u64::MAX >> size.leading_zeros(); // round size up to 2-power - 1
|
||||
let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1
|
||||
// the next two arrays form a linked list of nodes with matching bits 6..1
|
||||
let mut head = vec![size; 1 + mask as usize];
|
||||
let mut prev = vec![0usize; size];
|
||||
|
|
|
@ -63,7 +63,7 @@ impl PoWContext for CuckaroozContext {
|
|||
let nonces = &proof.nonces;
|
||||
let mut uvs = vec![0u64; 2 * size];
|
||||
let mut xoruv: u64 = 0;
|
||||
let mask = u64::MAX >> size.leading_zeros(); // round size up to 2-power - 1
|
||||
let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1
|
||||
// the next two arrays form a linked list of nodes with matching bits 6..1
|
||||
let mut head = vec![2 * size; 1 + mask as usize];
|
||||
let mut prev = vec![0usize; 2 * size];
|
||||
|
|
|
@ -261,7 +261,7 @@ impl CuckatooContext {
|
|||
}
|
||||
let nonces = &proof.nonces;
|
||||
let mut uvs = vec![0u64; 2 * size];
|
||||
let mask = u64::MAX >> size.leading_zeros(); // round size up to 2-power - 1
|
||||
let mask = u64::MAX >> (size as u64).leading_zeros(); // round size up to 2-power - 1
|
||||
let mut xor0: u64 = (size as u64 / 2) & 1;
|
||||
let mut xor1: u64 = xor0;
|
||||
// the next two arrays form a linked list of nodes with matching bits 6..1
|
||||
|
|
|
@ -729,7 +729,7 @@ impl WorkersList {
|
|||
|
||||
pub fn login(&self, worker_id: usize, login: String, agent: String) -> Result<(), RpcError> {
|
||||
let mut wl = self.workers_list.write();
|
||||
let mut worker = wl
|
||||
let worker = wl
|
||||
.get_mut(&worker_id)
|
||||
.ok_or_else(RpcError::internal_error)?;
|
||||
worker.login = Some(login);
|
||||
|
|
Loading…
Reference in a new issue