From 916d9cce57fe798516c472a2699ec71f97c2971a Mon Sep 17 00:00:00 2001 From: AntiochP <30642645+antiochp@users.noreply.github.com> Date: Thu, 18 Jan 2018 19:53:53 -0500 Subject: [PATCH] Revert "move siphash out of pow and into util" (#635) * Revert "move siphash out of pow and into util (#633)" This reverts commit dae90543c2c1df4e6290ba3ce9c7ad95395015a1. --- pow/src/cuckoo.rs | 2 +- pow/src/lib.rs | 1 + {util => pow}/src/siphash.rs | 44 ++++++++++++++++++------------------ util/src/lib.rs | 2 -- 4 files changed, 24 insertions(+), 25 deletions(-) rename {util => pow}/src/siphash.rs (77%) diff --git a/pow/src/cuckoo.rs b/pow/src/cuckoo.rs index b82d78a54..cd7859d2e 100644 --- a/pow/src/cuckoo.rs +++ b/pow/src/cuckoo.rs @@ -23,7 +23,7 @@ use std::cmp; use blake2; use core::core::Proof; -use util::siphash::siphash24; +use siphash::siphash24; use MiningWorker; const MAXPATHLEN: usize = 8192; diff --git a/pow/src/lib.rs b/pow/src/lib.rs index 4aee10871..9488c83a5 100644 --- a/pow/src/lib.rs +++ b/pow/src/lib.rs @@ -44,6 +44,7 @@ extern crate grin_util as util; extern crate cuckoo_miner; +mod siphash; pub mod plugin; pub mod cuckoo; pub mod types; diff --git a/util/src/siphash.rs b/pow/src/siphash.rs similarity index 77% rename from util/src/siphash.rs rename to pow/src/siphash.rs index d4fc1fe29..d1339dda2 100644 --- a/util/src/siphash.rs +++ b/pow/src/siphash.rs @@ -1,4 +1,4 @@ -// Copyright 2018 The Grin Developers +// Copyright 2016 The Grin Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,30 +24,30 @@ pub fn siphash24(v: [u64; 4], nonce: u64) -> u64 { // macro for left rotation macro_rules! rotl { - ($num:ident, $shift:expr) => { - $num = ($num << $shift) | ($num >> (64 - $shift)); - } - } + ($num:ident, $shift:expr) => { + $num = ($num << $shift) | ($num >> (64 - $shift)); + } + } // macro for a single siphash round macro_rules! round { - () => { - v0 = v0.wrapping_add(v1); - v2 = v2.wrapping_add(v3); - rotl!(v1, 13); - rotl!(v3, 16); - v1 ^= v0; - v3 ^= v2; - rotl!(v0, 32); - v2 = v2.wrapping_add(v1); - v0 = v0.wrapping_add(v3); - rotl!(v1, 17); - rotl!(v3, 21); - v1 ^= v2; - v3 ^= v0; - rotl!(v2, 32); - } - } + () => { + v0 = v0.wrapping_add(v1); + v2 = v2.wrapping_add(v3); + rotl!(v1, 13); + rotl!(v3, 16); + v1 ^= v0; + v3 ^= v2; + rotl!(v0, 32); + v2 = v2.wrapping_add(v1); + v0 = v0.wrapping_add(v3); + rotl!(v1, 17); + rotl!(v3, 21); + v1 ^= v2; + v3 ^= v0; + rotl!(v2, 32); + } + } // 2 rounds round!(); diff --git a/util/src/lib.rs b/util/src/lib.rs index 36f0b44f4..30b921b69 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -50,8 +50,6 @@ pub use secp_static::static_secp_instance; pub mod types; pub use types::{LoggingConfig, LogLevel}; -pub mod siphash; - // other utils use std::cell::{Ref, RefCell}; #[allow(unused_imports)]