bloom filter cleanup

This commit is contained in:
debris 2015-11-28 20:00:14 +01:00
parent faf174c245
commit addd1e5ffd

View File

@ -105,21 +105,20 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
/// TODO: optimize it, maybe non-recursive version?
/// TODO: clean up?
fn blocks(&self, bloom: &H2048, from_block: usize, to_block: usize, level: u8, offset: usize) -> Vec<usize> {
let mut result = vec![];
let index = self.bloom_index(offset, level);
match self.data_source.bloom_at_index(&index) {
None => (),
let contains = match self.data_source.bloom_at_index(&index) {
None => false,
Some(level_bloom) => match level {
0 => {
// to_block exclusive
if offset < to_block {
result.push(offset);
// if we are on the lowest level
// take the value, exclude to_block
0 if offset < to_block => return vec![offset],
0 => false,
_ => level_bloom.contains(bloom)
}
},
_ => match level_bloom.contains(bloom) {
false => (),
true => {
};
if contains {
let level_size = self.level_size(level - 1);
let from_index = self.bloom_index(from_block, level - 1);
let to_index = self.bloom_index(to_block, level - 1);
@ -135,10 +134,8 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
.collect();
return res
}
}
}
}
result
return vec![];
}
}