removed unnecessary maps
This commit is contained in:
parent
ad268d27d7
commit
394e57d3ce
@ -110,9 +110,8 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
|
|||||||
// map them to offsets
|
// map them to offsets
|
||||||
.map(|li| li.index * level_size)
|
.map(|li| li.index * level_size)
|
||||||
// get all blocks that may contain our bloom
|
// get all blocks that may contain our bloom
|
||||||
.map(|off| self.blocks(bloom, from_block, to_block, level - 1, off))
|
|
||||||
// filter existing ones
|
// filter existing ones
|
||||||
.filter_map(|x| x)
|
.filter_map(|off| self.blocks(bloom, from_block, to_block, level - 1, off))
|
||||||
// flatten nested structures
|
// flatten nested structures
|
||||||
.flat_map(|v| v)
|
.flat_map(|v| v)
|
||||||
.collect();
|
.collect();
|
||||||
@ -161,9 +160,8 @@ impl<'a, D> ChainFilter<'a, D> where D: FilterDataSource
|
|||||||
self.indexer.lower_level_bloom_indexes(&index)
|
self.indexer.lower_level_bloom_indexes(&index)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
// get blooms
|
// get blooms
|
||||||
.map(bloom_at)
|
|
||||||
// filter existing ones
|
// filter existing ones
|
||||||
.filter_map(|b| b)
|
.filter_map(bloom_at)
|
||||||
// BitOr all of them
|
// BitOr all of them
|
||||||
.fold(H2048::new(), |acc, bloom| acc | bloom)
|
.fold(H2048::new(), |acc, bloom| acc | bloom)
|
||||||
};
|
};
|
||||||
|
@ -482,8 +482,7 @@ impl BlockChainClient for Client {
|
|||||||
|
|
||||||
fn logs(&self, filter: Filter) -> Vec<LocalizedLogEntry> {
|
fn logs(&self, filter: Filter) -> Vec<LocalizedLogEntry> {
|
||||||
let mut blocks = filter.bloom_possibilities().iter()
|
let mut blocks = filter.bloom_possibilities().iter()
|
||||||
.map(|bloom| self.blocks_with_bloom(bloom, filter.from_block.clone(), filter.to_block.clone()))
|
.filter_map(|bloom| self.blocks_with_bloom(bloom, filter.from_block.clone(), filter.to_block.clone()))
|
||||||
.filter_map(|m| m)
|
|
||||||
.flat_map(|m| m)
|
.flat_map(|m| m)
|
||||||
// remove duplicate elements
|
// remove duplicate elements
|
||||||
.collect::<HashSet<u64>>()
|
.collect::<HashSet<u64>>()
|
||||||
@ -493,17 +492,14 @@ impl BlockChainClient for Client {
|
|||||||
blocks.sort();
|
blocks.sort();
|
||||||
|
|
||||||
blocks.into_iter()
|
blocks.into_iter()
|
||||||
.map(|number| self.chain.read().unwrap().block_hash(number).map(|hash| (number, hash)))
|
.filter_map(|number| self.chain.read().unwrap().block_hash(number).map(|hash| (number, hash)))
|
||||||
.filter_map(|m| m)
|
.filter_map(|(number, hash)| self.chain.read().unwrap().block_receipts(&hash).map(|r| (number, hash, r.receipts)))
|
||||||
.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())))
|
||||||
.filter_map(|m| m)
|
.flat_map(|(number, hash, receipts, hashes)| {
|
||||||
.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)| {
|
|
||||||
let mut log_index = 0;
|
let mut log_index = 0;
|
||||||
receipts.into_iter()
|
receipts.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(index, receipt)| {
|
.flat_map(|(index, receipt)| {
|
||||||
log_index += receipt.logs.len();
|
log_index += receipt.logs.len();
|
||||||
receipt.logs.into_iter()
|
receipt.logs.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
@ -518,11 +514,9 @@ impl BlockChainClient for Client {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<LocalizedLogEntry>>()
|
.collect::<Vec<LocalizedLogEntry>>()
|
||||||
})
|
})
|
||||||
.flat_map(|m| m)
|
|
||||||
.collect::<Vec<LocalizedLogEntry>>()
|
.collect::<Vec<LocalizedLogEntry>>()
|
||||||
|
|
||||||
})
|
})
|
||||||
.flat_map(|m| m)
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user