This commit is contained in:
debris 2015-11-28 17:10:14 +01:00
parent f0f70f801e
commit e769406b92
1 changed files with 20 additions and 16 deletions

View File

@ -81,7 +81,7 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
for i in 0..self.index_size {
indexes.insert(BloomIndex {
level: new_level,
index: offset + i
index: offset + i,
});
}
@ -101,7 +101,7 @@ impl<'a, D> Filter for ChainFilter<'a, D> where D: FilterDataSource
let bloom_index = self.bloom_index(block_number, level);
let new_bloom = match self.data_source.bloom_at_index(&bloom_index) {
Some(old_bloom) => old_bloom | bloom,
None => bloom.clone()
None => bloom.clone(),
};
result.insert(bloom_index, new_bloom);
@ -125,15 +125,15 @@ impl<'a, D> Filter for ChainFilter<'a, D> where D: FilterDataSource
Some(to_shift) => {
*to_shift = &blooms[i] | to_shift;
false
},
None => true
}
None => true,
};
// it hasn't been modified yet
if is_new_bloom {
let new_bloom = match self.data_source.bloom_at_index(&bloom_index) {
Some(old_bloom) => old_bloom | &blooms[i],
None => blooms[i].clone()
None => blooms[i].clone(),
};
result.insert(bloom_index, new_bloom);
}
@ -154,10 +154,10 @@ impl<'a, D> Filter for ChainFilter<'a, D> where D: FilterDataSource
let index = self.bloom_index(block_number, level);
let lower_indexes = self.lower_level_bloom_indexes(&index);
let new_bloom = lower_indexes.into_iter()
.filter(|li| li != &reset_index)
.map(|li| self.data_source.bloom_at_index(&li))
.filter_map(|b| b)
.fold(H2048::new(), | acc, bloom | { &acc | bloom });
.filter(|li| li != &reset_index)
.map(|li| self.data_source.bloom_at_index(&li))
.filter_map(|b| b)
.fold(H2048::new(), |acc, bloom| &acc | bloom);
reset_index = index.clone();
result.insert(index, &new_bloom | bloom);
@ -172,7 +172,11 @@ impl<'a, D> Filter for ChainFilter<'a, D> where D: FilterDataSource
}
/// returns numbers of blocks that may contain Address
fn blocks_with_address(&self, address: &Address, from_block: usize ,to_block: usize) -> Vec<usize> {
fn blocks_with_address(&self,
address: &Address,
from_block: usize,
to_block: usize)
-> Vec<usize> {
let mut bloom = H2048::new();
bloom.shift_bloom(&address.sha3());
self.blocks_with_bloom(&bloom, from_block, to_block)