From a14f2391ffae88f665fc375f78758fadeb4c37e1 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Wed, 29 Jun 2016 21:35:22 +0300 Subject: [PATCH] sorting with transaction result --- ethcore/src/client/client.rs.in | 4 ++- ethcore/src/miner/transaction_queue.rs | 10 +------ ethcore/src/types/block_queue_info.rs | 4 +++ ethcore/src/types/mod.rs.in | 1 + .../src/types/transaction_import_result.rs | 28 +++++++++++++++++++ 5 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 ethcore/src/types/transaction_import_result.rs diff --git a/ethcore/src/client/client.rs.in b/ethcore/src/client/client.rs.in index 1dc6512ab..cb0494696 100644 --- a/ethcore/src/client/client.rs.in +++ b/ethcore/src/client/client.rs.in @@ -797,7 +797,9 @@ 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).iter() + .map(|res| res.map_err(|e| format!("{:?}", e))) + .collect::>>() } fn queue_transactions(&self, transactions: Vec) { diff --git a/ethcore/src/miner/transaction_queue.rs b/ethcore/src/miner/transaction_queue.rs index b6c8d4edf..130d46875 100644 --- a/ethcore/src/miner/transaction_queue.rs +++ b/ethcore/src/miner/transaction_queue.rs @@ -90,6 +90,7 @@ use util::hash::{Address, H256}; use util::table::*; use transaction::*; use error::{Error, TransactionError}; +pub use types::transaction_import_result::TransactionImportResult; /// Transaction origin #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -310,15 +311,6 @@ pub struct TransactionQueueStatus { pub future: usize, } -#[derive(Debug, PartialEq)] -/// Represents the result of importing transaction. -pub enum TransactionImportResult { - /// Transaction was imported to current queue. - Current, - /// Transaction was imported to future queue. - Future -} - /// Details of account pub struct AccountDetails { /// Most recent account nonce diff --git a/ethcore/src/types/block_queue_info.rs b/ethcore/src/types/block_queue_info.rs index d6fd8a9cc..00e9b059f 100644 --- a/ethcore/src/types/block_queue_info.rs +++ b/ethcore/src/types/block_queue_info.rs @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +use std::mem; +use ipc::binary::BinaryConvertError; +use std::collections::VecDeque; + /// Block queue status #[derive(Debug, Binary)] pub struct BlockQueueInfo { diff --git a/ethcore/src/types/mod.rs.in b/ethcore/src/types/mod.rs.in index a60ee0f08..7f00550ff 100644 --- a/ethcore/src/types/mod.rs.in +++ b/ethcore/src/types/mod.rs.in @@ -26,3 +26,4 @@ pub mod block_status; pub mod account_diff; pub mod state_diff; pub mod block_queue_info; +pub mod transaction_import_result; diff --git a/ethcore/src/types/transaction_import_result.rs b/ethcore/src/types/transaction_import_result.rs new file mode 100644 index 000000000..632cf34c6 --- /dev/null +++ b/ethcore/src/types/transaction_import_result.rs @@ -0,0 +1,28 @@ +// 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 . + +use std::mem; +use ipc::binary::BinaryConvertError; +use std::collections::VecDeque; + +#[derive(Debug, PartialEq)] +/// Represents the result of importing transaction. +pub enum TransactionImportResult { + /// Transaction was imported to current queue. + Current, + /// Transaction was imported to future queue. + Future +}