From 5dd5983568f5bd69dd995555367cc95f50cc3bc0 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 6 Jul 2016 20:25:42 +0300 Subject: [PATCH] paste reformat mess fix --- ethcore/src/client/client.rs | 93 ++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 0426ec9b3..17b93723b 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -712,7 +712,7 @@ impl BlockChainClient for Client { fn transaction_receipt(&self, id: TransactionID) -> Option { self.transaction_address(id).and_then(|address| { let t = self.chain.block(&address.block_hash) - .and_then(|block| BlockView::new(&block).localized_transaction_at(address.index)); + .and_then(|block| BlockView::new(&block).localized_transaction_at(address.index)); match (t, self.chain.transaction_receipt(&address)) { (Some(tx), Some(receipt)) => { @@ -815,42 +815,41 @@ impl BlockChainClient for Client { // TODO: lock blockchain only once let mut blocks = filter.bloom_possibilities().iter() - .filter_map(|bloom| self.blocks_with_bloom(bloom, filter.from_block.clone(), filter.to_block.clone())) - .flat_map(|m| m) - // remove duplicate elements - .collect::>() - .into_iter() - .collect::>(); + .filter_map(|bloom| self.blocks_with_bloom(bloom, filter.from_block.clone(), filter.to_block.clone())) + .flat_map(|m| m) + // remove duplicate elements + .collect::>() + .into_iter() + .collect::>(); blocks.sort(); blocks.into_iter() - .filter_map(|number| self.chain.block_hash(number).map(|hash| (number, hash))) - .filter_map(|(number, hash)| self.chain.block_receipts(&hash).map(|r| (number, hash, r.receipts))) - .filter_map(|(number, hash, receipts)| self.chain.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() - .flat_map(|(index, receipt)| { - log_index += receipt.logs.len(); - receipt.logs.into_iter() - .enumerate() - .filter(|tuple| filter.matches(&tuple.1)) - .map(|(i, log)| LocalizedLogEntry { - entry: log, - block_hash: hash.clone(), - block_number: number, - transaction_hash: hashes.get(index).cloned().unwrap_or_else(H256::new), - transaction_index: index, - log_index: log_index + i - }) + .filter_map(|number| self.chain.block_hash(number).map(|hash| (number, hash))) + .filter_map(|(number, hash)| self.chain.block_receipts(&hash).map(|r| (number, hash, r.receipts))) + .filter_map(|(number, hash, receipts)| self.chain.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() + .flat_map(|(index, receipt)| { + log_index += receipt.logs.len(); + receipt.logs.into_iter() + .enumerate() + .filter(|tuple| filter.matches(&tuple.1)) + .map(|(i, log)| LocalizedLogEntry { + entry: log, + block_hash: hash.clone(), + block_number: number, + transaction_hash: hashes.get(index).cloned().unwrap_or_else(H256::new), + transaction_index: index, + log_index: log_index + i + }) + .collect::>() + }) .collect::>() }) - .collect::>() - - }) - .collect() + .collect() } fn filter_traces(&self, filter: TraceFilter) -> Option> { @@ -874,23 +873,23 @@ impl BlockChainClient for Client { fn trace(&self, trace: TraceId) -> Option { let trace_address = trace.address; self.transaction_address(trace.transaction) - .and_then(|tx_address| { - self.block_number(BlockID::Hash(tx_address.block_hash)) - .and_then(|number| self.tracedb.trace(number, tx_address.index, trace_address)) - }) + .and_then(|tx_address| { + self.block_number(BlockID::Hash(tx_address.block_hash)) + .and_then(|number| self.tracedb.trace(number, tx_address.index, trace_address)) + }) } fn transaction_traces(&self, transaction: TransactionID) -> Option> { self.transaction_address(transaction) - .and_then(|tx_address| { - self.block_number(BlockID::Hash(tx_address.block_hash)) - .and_then(|number| self.tracedb.transaction_traces(number, tx_address.index)) - }) + .and_then(|tx_address| { + self.block_number(BlockID::Hash(tx_address.block_hash)) + .and_then(|number| self.tracedb.transaction_traces(number, tx_address.index)) + }) } fn block_traces(&self, block: BlockID) -> Option> { self.block_number(block) - .and_then(|number| self.tracedb.block_traces(number)) + .and_then(|number| self.tracedb.block_traces(number)) } fn last_hashes(&self) -> LastHashes { @@ -938,13 +937,13 @@ impl MiningBlockChainClient for Client { // Add uncles self.chain - .find_uncle_headers(&h, engine.maximum_uncle_age()) - .unwrap() - .into_iter() - .take(engine.maximum_uncle_count()) - .foreach(|h| { - open_block.push_uncle(h).unwrap(); - }); + .find_uncle_headers(&h, engine.maximum_uncle_age()) + .unwrap() + .into_iter() + .take(engine.maximum_uncle_count()) + .foreach(|h| { + open_block.push_uncle(h).unwrap(); + }); open_block }