From edb86631954a18a810ca4ddeee5ee415cb9aab72 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Fri, 1 Jul 2016 22:34:50 +0300 Subject: [PATCH] ethcore finished --- ethcore/src/client/client.rs | 8 ++++++-- ethcore/src/client/mod.rs | 1 - ethcore/src/client/test_client.rs | 4 +++- ethcore/src/error.rs | 3 +-- ethcore/src/types/transaction_import.rs | 4 ++++ util/src/error.rs | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 655c66fde..522f1c457 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -21,7 +21,7 @@ use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; use util::*; use util::panics::*; use views::BlockView; -use error::{Error, ImportError, ExecutionError, BlockError, ImportResult}; +use error::{ImportError, ExecutionError, BlockError, ImportResult}; use header::{BlockNumber}; use state::State; use spec::Spec; @@ -779,7 +779,11 @@ impl BlockChainClient for Client { nonce: self.latest_nonce(a), balance: self.latest_balance(a), }; - self.miner.import_transactions(self, transactions, fetch_account) + + self.miner.import_transactions(self, transactions, &fetch_account) + .into_iter() + .map(|res| res.map_err(|e| e.into())) + .collect() } fn queue_transactions(&self, transactions: Vec) { diff --git a/ethcore/src/client/mod.rs b/ethcore/src/client/mod.rs index 54d38b034..c09da450d 100644 --- a/ethcore/src/client/mod.rs +++ b/ethcore/src/client/mod.rs @@ -47,7 +47,6 @@ use error::{ImportResult, ExecutionError}; use receipt::LocalizedReceipt; use trace::LocalizedTrace; use evm::Factory as EvmFactory; -use error::Error as EthError; pub use block_import_error::BlockImportError; pub use transaction_import::{TransactionImportResult, TransactionImportError}; diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 0ce308a30..1e51719c0 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -40,7 +40,6 @@ use error::{ExecutionError}; use trace::LocalizedTrace; use miner::{TransactionImportResult, AccountDetails}; -use error::Error as EthError; /// Test client. pub struct TestBlockChainClient { @@ -498,6 +497,9 @@ impl BlockChainClient for TestBlockChainClient { }; self.miner.import_transactions(self, transactions, &fetch_account) + .into_iter() + .map(|res| res.map_err(|e| e.into())) + .collect() } fn queue_transactions(&self, transactions: Vec) { diff --git a/ethcore/src/error.rs b/ethcore/src/error.rs index cfe6b3679..8c37e98ef 100644 --- a/ethcore/src/error.rs +++ b/ethcore/src/error.rs @@ -22,10 +22,9 @@ use basic_types::LogBloom; use client::Error as ClientError; pub use types::executed::ExecutionError; use ipc::binary::{BinaryConvertError, BinaryConvertable}; -use types::transaction_import::TransactionImportError; use types::block_import_error::BlockImportError; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] /// Errors concerning transaction processing. pub enum TransactionError { /// Transaction is already imported to the queue diff --git a/ethcore/src/types/transaction_import.rs b/ethcore/src/types/transaction_import.rs index fa7455cfd..c52a9fb80 100644 --- a/ethcore/src/types/transaction_import.rs +++ b/ethcore/src/types/transaction_import.rs @@ -20,6 +20,7 @@ use ipc::binary::{BinaryConvertError, BinaryConvertable}; use std::collections::VecDeque; use error::{TransactionError, Error}; use std::mem; +use util::Populatable; #[derive(Debug, Clone, PartialEq)] /// Represents the result of importing transaction. @@ -32,9 +33,12 @@ pub enum TransactionImportResult { binary_fixed_size!(TransactionImportResult); +/// Api-level error for transaction import #[derive(Debug, Clone, Binary)] pub enum TransactionImportError { + /// Transaction error Transaction(TransactionError), + /// Other error Other(String), } diff --git a/util/src/error.rs b/util/src/error.rs index 5e9f8e7a8..c5f40d717 100644 --- a/util/src/error.rs +++ b/util/src/error.rs @@ -101,7 +101,7 @@ impl fmt::Display for Mismatch { } } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone)] /// Error indicating value found is outside of a valid range. pub struct OutOfBounds { /// Minimum allowed value.