Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
fixed broken logs (#7934)
Browse files Browse the repository at this point in the history
* fixed broken logs

* bring back old lock order

* removed bloom groups from blockchain

* revert unrelated changes

* simplify blockchain_block_blooms
  • Loading branch information
debris authored and 5chdn committed Feb 22, 2018
1 parent e0b4506 commit f8a2e53
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 168 deletions.
192 changes: 70 additions & 122 deletions ethcore/src/blockchain/blockchain.rs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions ethcore/src/blockchain/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ pub struct CacheSize {
pub block_details: usize,
/// Transaction addresses cache size.
pub transaction_addresses: usize,
/// Blooms cache size.
pub blocks_blooms: usize,
/// Block receipts size.
pub block_receipts: usize,
}

impl CacheSize {
/// Total amount used by the cache.
pub fn total(&self) -> usize {
self.blocks + self.block_details + self.transaction_addresses + self.blocks_blooms + self.block_receipts
self.blocks + self.block_details + self.transaction_addresses + self.block_receipts
}
}
28 changes: 0 additions & 28 deletions ethcore/src/blockchain/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use std::ops;
use std::io::Write;
use blooms::{GroupPosition, BloomGroup};
use db::Key;
use engines::epoch::{Transition as EpochTransition};
use header::BlockNumber;
Expand All @@ -37,8 +36,6 @@ pub enum ExtrasIndex {
BlockHash = 1,
/// Transaction address index
TransactionAddress = 2,
/// Block blooms index
BlocksBlooms = 3,
/// Block receipts index
BlockReceipts = 4,
/// Epoch transition data index.
Expand Down Expand Up @@ -86,31 +83,6 @@ impl Key<BlockDetails> for H256 {
}
}

pub struct LogGroupKey([u8; 6]);

impl ops::Deref for LogGroupKey {
type Target = [u8];

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl Key<BloomGroup> for GroupPosition {
type Target = LogGroupKey;

fn key(&self) -> Self::Target {
let mut result = [0u8; 6];
result[0] = ExtrasIndex::BlocksBlooms as u8;
result[1] = self.level;
result[2] = (self.index >> 24) as u8;
result[3] = (self.index >> 16) as u8;
result[4] = (self.index >> 8) as u8;
result[5] = self.index as u8;
LogGroupKey(result)
}
}

impl Key<TransactionAddress> for H256 {
type Target = H264;

Expand Down
5 changes: 5 additions & 0 deletions ethcore/src/blockchain/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ impl Block {
pub fn encoded(&self) -> Bytes {
encode(self).into_vec()
}

#[inline]
pub fn difficulty(&self) -> U256 {
*self.header.difficulty()
}
}

#[derive(Debug)]
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/blockchain/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use ethereum_types::H256;
use header::BlockNumber;
use blockchain::block_info::BlockInfo;
use blockchain::extras::{BlockDetails, BlockReceipts, TransactionAddress};
use blooms::{BloomGroup, GroupPosition};

/// Block extras update info.
pub struct ExtrasUpdate<'a> {
Expand All @@ -19,8 +18,6 @@ pub struct ExtrasUpdate<'a> {
pub block_details: HashMap<H256, BlockDetails>,
/// Modified block receipts.
pub block_receipts: HashMap<H256, BlockReceipts>,
/// Modified blocks blooms.
pub blocks_blooms: HashMap<GroupPosition, BloomGroup>,
/// Modified transaction addresses (None signifies removed transactions).
pub transactions_addresses: HashMap<H256, Option<TransactionAddress>>,
}
13 changes: 2 additions & 11 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,17 +1677,8 @@ impl BlockChainClient for Client {
};

let chain = self.chain.read();
let blocks = filter.bloom_possibilities().iter()
.map(move |bloom| {
chain.blocks_with_bloom(bloom, from, to)
})
.flat_map(|m| m)
// remove duplicate elements
.collect::<HashSet<u64>>()
.into_iter()
.collect::<Vec<u64>>();

self.chain.read().logs(blocks, |entry| filter.matches(entry), filter.limit)
let blocks = chain.blocks_with_blooms(&filter.bloom_possibilities(), from, to);
chain.logs(blocks, |entry| filter.matches(entry), filter.limit)
}

fn filter_traces(&self, filter: TraceFilter) -> Option<Vec<LocalizedTrace>> {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/verification/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ mod tests {
unimplemented!()
}

fn blocks_with_bloom(&self, _bloom: &Bloom, _from_block: BlockNumber, _to_block: BlockNumber) -> Vec<BlockNumber> {
fn blocks_with_blooms(&self, _blooms: &[Bloom], _from_block: BlockNumber, _to_block: BlockNumber) -> Vec<BlockNumber> {
unimplemented!()
}

Expand Down

0 comments on commit f8a2e53

Please sign in to comment.