diff --git a/ethcore/src/chainfilter/chainfilter.rs b/ethcore/src/chainfilter/chainfilter.rs index e0a281f12..fb6df877a 100644 --- a/ethcore/src/chainfilter/chainfilter.rs +++ b/ethcore/src/chainfilter/chainfilter.rs @@ -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) }; diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 18ce28c6b..9244c26fc 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -482,8 +482,7 @@ impl BlockChainClient for Client { fn logs(&self, filter: Filter) -> Vec { 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::>() @@ -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::>() }) - .flat_map(|m| m) .collect::>() }) - .flat_map(|m| m) .collect() } }