removed unnecessary maps

This commit is contained in:
debris 2016-02-24 10:23:25 +01:00
parent ad268d27d7
commit 394e57d3ce
2 changed files with 8 additions and 16 deletions

View File

@ -110,9 +110,8 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
// map them to offsets
.map(|li| li.index * level_size)
// get all blocks that may contain our bloom
.map(|off| self.blocks(bloom, from_block, to_block, level - 1, off))
// filter existing ones
.filter_map(|x| x)
.filter_map(|off| self.blocks(bloom, from_block, to_block, level - 1, off))
// flatten nested structures
.flat_map(|v| v)
.collect();
@ -161,9 +160,8 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
self.indexer.lower_level_bloom_indexes(&index)
.into_iter()
// get blooms
.map(bloom_at)
// filter existing ones
.filter_map(|b| b)
.filter_map(bloom_at)
// BitOr all of them
.fold(H2048::new(), |acc, bloom| acc | bloom)
};

View File

@ -482,8 +482,7 @@ impl BlockChainClient for Client {
fn logs(&self, filter: Filter) -> Vec<LocalizedLogEntry> {
let mut blocks = filter.bloom_possibilities().iter()
.map(|bloom| self.blocks_with_bloom(bloom, filter.from_block.clone(), filter.to_block.clone()))
.filter_map(|m| m)
.filter_map(|bloom| self.blocks_with_bloom(bloom, filter.from_block.clone(), filter.to_block.clone()))
.flat_map(|m| m)
// remove duplicate elements
.collect::<HashSet<u64>>()
@ -493,17 +492,14 @@ impl BlockChainClient for Client {
blocks.sort();
blocks.into_iter()
.map(|number| self.chain.read().unwrap().block_hash(number).map(|hash| (number, hash)))
.filter_map(|m| m)
.map(|(number, hash)| self.chain.read().unwrap().block_receipts(&hash).map(|r| (number, hash, r.receipts)))
.filter_map(|m| m)
.map(|(number, hash, receipts)| self.chain.read().unwrap().block(&hash).map(|ref b| (number, hash, receipts, BlockView::new(b).transaction_hashes())))
.filter_map(|m| m)
.map(|(number, hash, receipts, hashes)| {
.filter_map(|number| self.chain.read().unwrap().block_hash(number).map(|hash| (number, hash)))
.filter_map(|(number, hash)| self.chain.read().unwrap().block_receipts(&hash).map(|r| (number, hash, r.receipts)))
.filter_map(|(number, hash, receipts)| self.chain.read().unwrap().block(&hash).map(|ref b| (number, hash, receipts, BlockView::new(b).transaction_hashes())))
.flat_map(|(number, hash, receipts, hashes)| {
let mut log_index = 0;
receipts.into_iter()
.enumerate()
.map(|(index, receipt)| {
.flat_map(|(index, receipt)| {
log_index += receipt.logs.len();
receipt.logs.into_iter()
.enumerate()
@ -518,11 +514,9 @@ impl BlockChainClient for Client {
})
.collect::<Vec<LocalizedLogEntry>>()
})
.flat_map(|m| m)
.collect::<Vec<LocalizedLogEntry>>()
})
.flat_map(|m| m)
.collect()
}
}