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