From 2805dfe22dda728f062ca3f9535704c5ba7ca961 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 4 Dec 2015 11:40:54 +0100 Subject: [PATCH] removed num library from dependencies --- Cargo.toml | 1 - src/chainfilter.rs | 17 ++++++++++++----- src/lib.rs | 1 - 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 41ca44580..65ea8508f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ rand = "0.3.12" time = "0.1.34" tiny-keccak = "1.0" rocksdb = "0.2.1" -num = "0.1" lazy_static = "0.1.*" secp256k1 = "0.5.1" rust-crypto = "0.2.34" diff --git a/src/chainfilter.rs b/src/chainfilter.rs index 538d1883f..076263fbb 100644 --- a/src/chainfilter.rs +++ b/src/chainfilter.rs @@ -41,7 +41,6 @@ use std::collections::{HashMap}; use hash::*; use sha3::*; -use num::pow; /// Represents bloom index in cache /// @@ -119,13 +118,21 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource let mut filter = ChainFilter { data_source: data_source, index_size: index_size, - level_sizes: vec![] + // 0 level has always a size of 1 + level_sizes: vec![1] }; // cache level sizes, so we do not have to calculate them all the time - for i in 0..levels { - filter.level_sizes.push(pow(index_size, i as usize)); - } + // eg. if levels == 3, index_size = 16 + // level_sizes = [1, 16, 256] + let additional: Vec = (1..).into_iter() + .scan(1, |acc, _| { + *acc = *acc * index_size; + Some(*acc) + }) + .take(levels as usize - 1) + .collect(); + filter.level_sizes.extend(additional); filter } diff --git a/src/lib.rs b/src/lib.rs index 1de5c7ca8..6366d682e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,6 @@ extern crate mio; extern crate rand; extern crate rocksdb; extern crate tiny_keccak; -extern crate num; #[macro_use] extern crate log; #[macro_use]