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: optimize it, maybe non-recursive version?
/// TODO: clean up? /// TODO: clean up?
fn blocks(&self, bloom: &H2048, from_block: usize, to_block: usize, level: u8, offset: usize) -> Vec<usize> { 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); let index = self.bloom_index(offset, level);
match self.data_source.bloom_at_index(&index) { let contains = match self.data_source.bloom_at_index(&index) {
None => (), None => false,
Some(level_bloom) => match level { Some(level_bloom) => match level {
0 => { // if we are on the lowest level
// to_block exclusive // take the value, exclude to_block
if offset < to_block { 0 if offset < to_block => return vec![offset],
result.push(offset); 0 => false,
_ => level_bloom.contains(bloom)
} }
}, };
_ => match level_bloom.contains(bloom) {
false => (), if contains {
true => {
let level_size = self.level_size(level - 1); let level_size = self.level_size(level - 1);
let from_index = self.bloom_index(from_block, level - 1); let from_index = self.bloom_index(from_block, level - 1);
let to_index = self.bloom_index(to_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(); .collect();
return res return res
} }
}
} return vec![];
}
result
} }
} }