moved BlockId and TransactionId to blockchain.rs

This commit is contained in:
debris 2016-02-10 15:06:13 +01:00
parent 75b54cc277
commit dc8fa4ebfd
5 changed files with 22 additions and 20 deletions

View File

@ -23,6 +23,24 @@ use extras::*;
use transaction::*; use transaction::*;
use views::*; 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: /// Represents a tree route between `from` block and `to` block:
pub struct TreeRoute { pub struct TreeRoute {
/// A vector of hashes of all blocks, ordered from `from` to `to`. /// A vector of hashes of all blocks, ordered from `from` to `to`.
@ -674,7 +692,6 @@ mod tests {
use util::hash::*; use util::hash::*;
use blockchain::*; use blockchain::*;
use tests::helpers::*; use tests::helpers::*;
use views::TransactionId;
#[test] #[test]
fn valid_tests_extra32() { fn valid_tests_extra32() {

View File

@ -18,8 +18,8 @@
use util::*; use util::*;
use rocksdb::{Options, DB, DBCompactionStyle}; use rocksdb::{Options, DB, DBCompactionStyle};
use blockchain::{BlockChain, BlockProvider, CacheSize}; use blockchain::{BlockChain, BlockProvider, CacheSize, TransactionId};
use views::{BlockView, TransactionId}; use views::BlockView;
use error::*; use error::*;
use header::BlockNumber; use header::BlockNumber;
use state::State; use state::State;

View File

@ -19,22 +19,6 @@ use util::*;
use header::*; use header::*;
use transaction::*; 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. /// View onto transaction rlp.
pub struct TransactionView<'a> { pub struct TransactionView<'a> {
rlp: Rlp<'a> rlp: Rlp<'a>

View File

@ -22,6 +22,7 @@ use util::uint::*;
use util::sha3::*; use util::sha3::*;
use ethcore::client::*; use ethcore::client::*;
use ethcore::views::*; use ethcore::views::*;
use ethcore::blockchain::{BlockId, TransactionId};
use v1::traits::{Eth, EthFilter}; use v1::traits::{Eth, EthFilter};
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, Transaction, OptionalValue, Index}; use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, Transaction, OptionalValue, Index};

View File

@ -23,7 +23,7 @@ use io::SyncIo;
use chain::{ChainSync}; use chain::{ChainSync};
use ethcore::receipt::Receipt; use ethcore::receipt::Receipt;
use ethcore::transaction::LocalizedTransaction; use ethcore::transaction::LocalizedTransaction;
use ethcore::views::TransactionId; use ethcore::blockchain::TransactionId;
pub struct TestBlockChainClient { pub struct TestBlockChainClient {
pub blocks: RwLock<HashMap<H256, Bytes>>, pub blocks: RwLock<HashMap<H256, Bytes>>,