diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index feedf1247c6..2e0cb1557e8 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -27,14 +27,14 @@ use parking_lot::{Mutex, RwLock}; use bytes::Bytes; use rlp::*; use header::*; -use super::extras::*; use transaction::*; use views::*; use log_entry::{LogEntry, LocalizedLogEntry}; use receipt::Receipt; -use blooms::BloomGroup; -use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData}; +use blooms::{BloomGroup, GroupPosition}; use blockchain::best_block::{BestBlock, BestAncientBlock}; +use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData}; +use blockchain::extras::{BlockReceipts, BlockDetails, TransactionAddress, EPOCH_KEY_PREFIX, EpochTransitions}; use types::blockchain_info::BlockChainInfo; use types::tree_route::TreeRoute; use blockchain::update::ExtrasUpdate; @@ -163,13 +163,13 @@ enum CacheId { BlockDetails(H256), BlockHashes(BlockNumber), TransactionAddresses(H256), - BlocksBlooms(LogGroupPosition), + BlocksBlooms(GroupPosition), BlockReceipts(H256), } impl bc::group::BloomGroupDatabase for BlockChain { fn blooms_at(&self, position: &bc::group::GroupPosition) -> Option { - let position = LogGroupPosition::from(position.clone()); + let position = GroupPosition::from(position.clone()); let result = self.db.read_with_cache(db::COL_EXTRA, &self.blocks_blooms, &position).map(Into::into); self.cache_man.lock().note_used(CacheId::BlocksBlooms(position)); result @@ -199,7 +199,7 @@ pub struct BlockChain { block_details: RwLock>, block_hashes: RwLock>, transaction_addresses: RwLock>, - blocks_blooms: RwLock>, + blocks_blooms: RwLock>, block_receipts: RwLock>, db: Arc, @@ -1260,7 +1260,7 @@ impl BlockChain { /// Later, BloomIndexer is used to map bloom location on filter layer (BloomIndex) /// to bloom location in database (BlocksBloomLocation). /// - fn prepare_block_blooms_update(&self, block_bytes: &[u8], info: &BlockInfo) -> HashMap { + fn prepare_block_blooms_update(&self, block_bytes: &[u8], info: &BlockInfo) -> HashMap { let block = BlockView::new(block_bytes); let header = block.header_view(); diff --git a/ethcore/src/blockchain/extras.rs b/ethcore/src/blockchain/extras.rs index d49d5c8d580..97583a693a6 100644 --- a/ethcore/src/blockchain/extras.rs +++ b/ethcore/src/blockchain/extras.rs @@ -18,7 +18,6 @@ use std::ops; use std::io::Write; -use bloomchain; use blooms::{GroupPosition, BloomGroup}; use db::Key; use engines::epoch::{Transition as EpochTransition}; @@ -97,32 +96,17 @@ impl ops::Deref for LogGroupKey { } } -#[derive(Debug, PartialEq, Eq, Hash, Clone)] -pub struct LogGroupPosition(GroupPosition); - -impl From for LogGroupPosition { - fn from(position: bloomchain::group::GroupPosition) -> Self { - LogGroupPosition(From::from(position)) - } -} - -impl HeapSizeOf for LogGroupPosition { - fn heap_size_of_children(&self) -> usize { - self.0.heap_size_of_children() - } -} - -impl Key for LogGroupPosition { +impl Key for GroupPosition { type Target = LogGroupKey; fn key(&self) -> Self::Target { let mut result = [0u8; 6]; result[0] = ExtrasIndex::BlocksBlooms as u8; - result[1] = self.0.level; - result[2] = (self.0.index >> 24) as u8; - result[3] = (self.0.index >> 16) as u8; - result[4] = (self.0.index >> 8) as u8; - result[5] = self.0.index 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) } } diff --git a/ethcore/src/blockchain/mod.rs b/ethcore/src/blockchain/mod.rs index 55a67e2b65e..062068c704d 100644 --- a/ethcore/src/blockchain/mod.rs +++ b/ethcore/src/blockchain/mod.rs @@ -18,10 +18,10 @@ mod best_block; mod block_info; -pub mod blockchain; +mod blockchain; mod cache; mod config; -pub mod extras; +mod extras; mod import_route; mod update; @@ -31,5 +31,6 @@ pub mod generator; pub use self::blockchain::{BlockProvider, BlockChain}; pub use self::cache::CacheSize; pub use self::config::Config; -pub use types::tree_route::TreeRoute; +pub use self::extras::{BlockReceipts, BlockDetails, TransactionAddress}; pub use self::import_route::ImportRoute; +pub use types::tree_route::TreeRoute; diff --git a/ethcore/src/blockchain/update.rs b/ethcore/src/blockchain/update.rs index a54fed052f6..467ccc8d17b 100644 --- a/ethcore/src/blockchain/update.rs +++ b/ethcore/src/blockchain/update.rs @@ -2,8 +2,8 @@ use std::collections::HashMap; use ethereum_types::H256; use header::BlockNumber; use blockchain::block_info::BlockInfo; -use blooms::BloomGroup; -use super::extras::{BlockDetails, BlockReceipts, TransactionAddress, LogGroupPosition}; +use blockchain::extras::{BlockDetails, BlockReceipts, TransactionAddress}; +use blooms::{BloomGroup, GroupPosition}; /// Block extras update info. pub struct ExtrasUpdate<'a> { @@ -20,7 +20,7 @@ pub struct ExtrasUpdate<'a> { /// Modified block receipts. pub block_receipts: HashMap, /// Modified blocks blooms. - pub blocks_blooms: HashMap, + pub blocks_blooms: HashMap, /// Modified transaction addresses (None signifies removed transactions). pub transactions_addresses: HashMap>, } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 08faf286f84..8eb8c483349 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -34,8 +34,7 @@ use kvdb::{DBValue, KeyValueDB, DBTransaction}; // other use ethereum_types::{H256, Address, U256}; use block::*; -use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute}; -use blockchain::extras::TransactionAddress; +use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute, TransactionAddress}; use client::ancient_import::AncientVerifier; use client::Error as ClientError; use client::{ diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 0fec09014f8..f1561f3e6ab 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -33,7 +33,7 @@ use rlp::*; use ethkey::{Generator, Random}; use tempdir::TempDir; use transaction::{self, Transaction, LocalizedTransaction, PendingTransaction, SignedTransaction, Action}; -use blockchain::TreeRoute; +use blockchain::{TreeRoute, BlockReceipts}; use client::{ BlockChainClient, MiningBlockChainClient, BlockChainInfo, BlockStatus, BlockId, TransactionId, UncleId, TraceId, TraceFilter, LastHashes, CallAnalytics, BlockImportError, @@ -44,7 +44,6 @@ use header::{Header as BlockHeader, BlockNumber}; use filter::Filter; use log_entry::LocalizedLogEntry; use receipt::{Receipt, LocalizedReceipt, TransactionOutcome}; -use blockchain::extras::BlockReceipts; use error::{ImportResult, Error as EthcoreError}; use evm::{Factory as EvmFactory, VMType}; use vm::Schedule; diff --git a/ethcore/src/client/trace.rs b/ethcore/src/client/trace.rs index 4236aeaf420..75e0fe34a1e 100644 --- a/ethcore/src/client/trace.rs +++ b/ethcore/src/client/trace.rs @@ -4,8 +4,7 @@ use ethereum_types::H256; use header::BlockNumber; use trace::DatabaseExtras as TraceDatabaseExtras; -use blockchain::{BlockChain, BlockProvider}; -use blockchain::extras::TransactionAddress; +use blockchain::{BlockChain, BlockProvider, TransactionAddress}; pub use types::trace_filter::Filter; impl TraceDatabaseExtras for BlockChain { diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 10cd3f6cbcc..5e3bc7ea2ba 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -337,7 +337,7 @@ mod tests { use std::collections::{BTreeMap, HashMap}; use ethereum_types::{H256, Bloom, U256}; - use blockchain::extras::{BlockDetails, TransactionAddress, BlockReceipts}; + use blockchain::{BlockDetails, TransactionAddress, BlockReceipts}; use encoded; use hash::keccak; use engines::EthEngine;