From dc8fa4ebfdf8ae7de4124c895b8fe058a7fda88e Mon Sep 17 00:00:00 2001 From: debris Date: Wed, 10 Feb 2016 15:06:13 +0100 Subject: [PATCH] moved BlockId and TransactionId to blockchain.rs --- ethcore/src/blockchain.rs | 19 ++++++++++++++++++- ethcore/src/client.rs | 4 ++-- ethcore/src/views.rs | 16 ---------------- rpc/src/v1/impls/eth.rs | 1 + sync/src/tests/helpers.rs | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ethcore/src/blockchain.rs b/ethcore/src/blockchain.rs index febadfc52..f7c45d94e 100644 --- a/ethcore/src/blockchain.rs +++ b/ethcore/src/blockchain.rs @@ -23,6 +23,24 @@ use extras::*; use transaction::*; use views::*; +/// Uniquely identifies block. +pub enum BlockId { + /// Block's sha3. + /// Querying by hash is always faster. + Hash(H256), + /// Block number within canon blockchain. + Number(BlockNumber) +} + +/// Uniquely identifies transaction. +pub enum TransactionId { + /// Transaction's sha3. + Hash(H256), + /// Block id and transaction index within this block. + /// Querying by block position is always faster. + BlockPosition(BlockId, usize) +} + /// Represents a tree route between `from` block and `to` block: pub struct TreeRoute { /// A vector of hashes of all blocks, ordered from `from` to `to`. @@ -674,7 +692,6 @@ mod tests { use util::hash::*; use blockchain::*; use tests::helpers::*; - use views::TransactionId; #[test] fn valid_tests_extra32() { diff --git a/ethcore/src/client.rs b/ethcore/src/client.rs index 93038af48..3de5c097e 100644 --- a/ethcore/src/client.rs +++ b/ethcore/src/client.rs @@ -18,8 +18,8 @@ use util::*; use rocksdb::{Options, DB, DBCompactionStyle}; -use blockchain::{BlockChain, BlockProvider, CacheSize}; -use views::{BlockView, TransactionId}; +use blockchain::{BlockChain, BlockProvider, CacheSize, TransactionId}; +use views::BlockView; use error::*; use header::BlockNumber; use state::State; diff --git a/ethcore/src/views.rs b/ethcore/src/views.rs index a49c06708..4a7ff054d 100644 --- a/ethcore/src/views.rs +++ b/ethcore/src/views.rs @@ -19,22 +19,6 @@ use util::*; use header::*; use transaction::*; -/// Uniquely identifies block. -pub enum BlockId { - /// Block's sha3. - Hash(H256), - /// Block number within canon blockchain. - Number(BlockNumber) -} - -/// Uniquely identifies transaction. -pub enum TransactionId { - /// Transaction's sha3. - Hash(H256), - /// Block id and transaction index within this block. - BlockPosition(BlockId, usize) -} - /// View onto transaction rlp. pub struct TransactionView<'a> { rlp: Rlp<'a> diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index c21157599..32c1919bf 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -22,6 +22,7 @@ use util::uint::*; use util::sha3::*; use ethcore::client::*; use ethcore::views::*; +use ethcore::blockchain::{BlockId, TransactionId}; use v1::traits::{Eth, EthFilter}; use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, Transaction, OptionalValue, Index}; diff --git a/sync/src/tests/helpers.rs b/sync/src/tests/helpers.rs index d392fc653..f8c08dc93 100644 --- a/sync/src/tests/helpers.rs +++ b/sync/src/tests/helpers.rs @@ -23,7 +23,7 @@ use io::SyncIo; use chain::{ChainSync}; use ethcore::receipt::Receipt; use ethcore::transaction::LocalizedTransaction; -use ethcore::views::TransactionId; +use ethcore::blockchain::TransactionId; pub struct TestBlockChainClient { pub blocks: RwLock>,