From 8ac3af68a4c48d266655a3b63d1bc01203642772 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Mon, 5 Oct 2020 09:21:40 +0200 Subject: [PATCH] use u128 in map_to_range --- src/util/bip158.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/util/bip158.rs b/src/util/bip158.rs index 6a8f8c20..5f209cc3 100644 --- a/src/util/bip158.rs +++ b/src/util/bip158.rs @@ -321,20 +321,7 @@ impl GCSFilterReader { // fast reduction of hash to [0, nm) range fn map_to_range(hash: u64, nm: u64) -> u64 { - // Use this once we upgrade to rustc >= 1.26 - // ((hash as u128 * nm as u128) >> 64) as u64 - - #[inline] - fn l(n: u64) -> u64 { n & 0xffffffff } - #[inline] - fn h(n: u64) -> u64 { n >> 32 } - - let a = h(hash); - let b = l(hash); - let c = h(nm); - let d = l(nm); - - a * c + h(a * d + c * b + h(b * d)) + ((hash as u128 * nm as u128) >> 64) as u64 } /// Colomb-Rice encoded filter writer