dedicated types
This commit is contained in:
parent
0907722fc8
commit
07521c17b4
@ -49,6 +49,8 @@ use trace::LocalizedTrace;
|
|||||||
use evm::Factory as EvmFactory;
|
use evm::Factory as EvmFactory;
|
||||||
use miner::{TransactionImportResult};
|
use miner::{TransactionImportResult};
|
||||||
use error::Error as EthError;
|
use error::Error as EthError;
|
||||||
|
pub use block_import_error::BlockImportError;
|
||||||
|
pub use transaction_import::{TransactionImportResult, TransactionImportError};
|
||||||
|
|
||||||
/// Options concerning what analytics we run on the call.
|
/// Options concerning what analytics we run on the call.
|
||||||
#[derive(Eq, PartialEq, Default, Clone, Copy, Debug)]
|
#[derive(Eq, PartialEq, Default, Clone, Copy, Debug)]
|
||||||
@ -188,7 +190,7 @@ pub trait BlockChainClient : Sync + Send {
|
|||||||
fn last_hashes(&self) -> LastHashes;
|
fn last_hashes(&self) -> LastHashes;
|
||||||
|
|
||||||
/// import transactions from network/other 3rd party
|
/// import transactions from network/other 3rd party
|
||||||
fn import_transactions(&self, transactions: Vec<SignedTransaction>) -> Vec<Result<TransactionImportResult, EthError>>;
|
fn import_transactions(&self, transactions: Vec<SignedTransaction>) -> Vec<Result<TransactionImportResult, TransactionImportError>>;
|
||||||
|
|
||||||
/// Queue transactions for importing.
|
/// Queue transactions for importing.
|
||||||
fn queue_transactions(&self, transactions: Vec<Bytes>);
|
fn queue_transactions(&self, transactions: Vec<Bytes>);
|
||||||
|
@ -250,7 +250,7 @@ impl fmt::Display for Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Result of import block operation.
|
/// Result of import block operation.
|
||||||
pub type ImportResult = Result<H256, Error>;
|
pub type ImportResult = Result<H256, BlockImportError>;
|
||||||
|
|
||||||
impl From<ClientError> for Error {
|
impl From<ClientError> for Error {
|
||||||
fn from(err: ClientError) -> Error {
|
fn from(err: ClientError) -> Error {
|
||||||
@ -312,6 +312,21 @@ impl From<TrieError> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<BlockImportError> for Error {
|
||||||
|
fn from(err: BlockImportError) -> Error {
|
||||||
|
match err {
|
||||||
|
BlockImportError::Block(e) => Error::Block(e),
|
||||||
|
BlockImportError::Import(e) => Error::Import(e),
|
||||||
|
BlockImportError::Other(s) => Error::Util(UtilError::SimpleString(s)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binary_fixed_size!(BlockError);
|
||||||
|
binary_fixed_size!(ImportError);
|
||||||
|
binary_fixed_size!(TransactionError);
|
||||||
|
|
||||||
|
|
||||||
// TODO: uncomment below once https://github.com/rust-lang/rust/issues/27336 sorted.
|
// TODO: uncomment below once https://github.com/rust-lang/rust/issues/27336 sorted.
|
||||||
/*#![feature(concat_idents)]
|
/*#![feature(concat_idents)]
|
||||||
macro_rules! assimilate {
|
macro_rules! assimilate {
|
||||||
|
44
ethcore/src/types/block_import_error.rs
Normal file
44
ethcore/src/types/block_import_error.rs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Block import error related types
|
||||||
|
|
||||||
|
use std::mem;
|
||||||
|
use ipc::binary::BinaryConvertError;
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
use error::{ImportError, BlockError, Error};
|
||||||
|
use std::convert::From;
|
||||||
|
|
||||||
|
/// Error dedicated to import block function
|
||||||
|
#[derive(Binary, Debug)]
|
||||||
|
pub enum BlockImportError {
|
||||||
|
/// Import error
|
||||||
|
Import(ImportError),
|
||||||
|
/// Block error
|
||||||
|
Block(BlockError),
|
||||||
|
/// Other error
|
||||||
|
Other(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Error> for BlockImportError {
|
||||||
|
fn from(e: Error) -> Self {
|
||||||
|
match e {
|
||||||
|
Error::Block(block_error) => BlockImportError::Block(block_error),
|
||||||
|
Error::Import(import_error) => BlockImportError::Import(import_error),
|
||||||
|
_ => BlockImportError::Other(format!("other block import error: {:?}", e)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,3 +25,5 @@ pub mod executed;
|
|||||||
pub mod block_status;
|
pub mod block_status;
|
||||||
pub mod account_diff;
|
pub mod account_diff;
|
||||||
pub mod state_diff;
|
pub mod state_diff;
|
||||||
|
pub mod transaction_import;
|
||||||
|
pub mod block_import_error;
|
||||||
|
46
ethcore/src/types/transaction_import.rs
Normal file
46
ethcore/src/types/transaction_import.rs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Transaction import result related types
|
||||||
|
|
||||||
|
use ipc::binary::BinaryConvertError;
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
/// Represents the result of importing transaction.
|
||||||
|
pub enum TransactionImportResult {
|
||||||
|
/// Transaction was imported to current queue.
|
||||||
|
Current,
|
||||||
|
/// Transaction was imported to future queue.
|
||||||
|
Future
|
||||||
|
}
|
||||||
|
|
||||||
|
binary_fixed_size!(TransactionImportResult);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Binary)]
|
||||||
|
pub enum TransactionImportError {
|
||||||
|
Transaction(TransactionError),
|
||||||
|
Other(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Error> for BlockImportError {
|
||||||
|
fn from(e: Error) -> Self {
|
||||||
|
match e {
|
||||||
|
Error::Transaction(transaction_error) => TransactionImportError::Transaction(block_error),
|
||||||
|
_ => TransactionImportError::Other(format!("other block import error: {:?}", e)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user