transaction import result sorting also

This commit is contained in:
NikVolf 2016-06-29 21:48:22 +03:00
parent f6ec1eae4a
commit d5be0fae54
4 changed files with 13 additions and 7 deletions

View File

@ -39,6 +39,8 @@ use util::journaldb::JournalDB;
use util::kvdb::*; use util::kvdb::*;
use util::Itertools; use util::Itertools;
use util::PerfTimer; use util::PerfTimer;
use util::View;
use util::Stream;
// other // other
use views::BlockView; use views::BlockView;
@ -501,7 +503,7 @@ impl Client {
} }
} }
#[derive(Ipc)] //#[derive(Ipc)]
impl BlockChainClient for Client { impl BlockChainClient for Client {
fn call(&self, t: &SignedTransaction, analytics: CallAnalytics) -> Result<Executed, ExecutionError> { fn call(&self, t: &SignedTransaction, analytics: CallAnalytics) -> Result<Executed, ExecutionError> {
let header = self.block_header(BlockID::Latest).unwrap(); let header = self.block_header(BlockID::Latest).unwrap();
@ -798,8 +800,9 @@ impl BlockChainClient for Client {
nonce: self.latest_nonce(a), nonce: self.latest_nonce(a),
balance: self.latest_balance(a), balance: self.latest_balance(a),
}; };
self.miner.import_transactions(self, transactions, fetch_account).iter() self.miner.import_transactions(self, transactions, fetch_account)
.map(|res| res.map_err(|e| format!("{:?}", e))) .iter()
.map(|res| match res { &Ok(ref t) => Ok(t.clone()), &Err(ref e) => Err(format!("{:?}", e)) })
.collect::<Vec<Result<TransactionImportResult, String>>>() .collect::<Vec<Result<TransactionImportResult, String>>>()
} }

View File

@ -188,7 +188,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, String>>;
/// Queue transactions for importing. /// Queue transactions for importing.
fn queue_transactions(&self, transactions: Vec<Bytes>); fn queue_transactions(&self, transactions: Vec<Bytes>);

View File

@ -483,7 +483,7 @@ impl BlockChainClient for TestBlockChainClient {
unimplemented!(); unimplemented!();
} }
fn import_transactions(&self, transactions: Vec<SignedTransaction>) -> Vec<Result<TransactionImportResult, EthError>> { fn import_transactions(&self, transactions: Vec<SignedTransaction>) -> Vec<Result<TransactionImportResult, String>> {
let nonces = self.nonces.read().unwrap(); let nonces = self.nonces.read().unwrap();
let balances = self.balances.read().unwrap(); let balances = self.balances.read().unwrap();
let fetch_account = |a: &Address| AccountDetails { let fetch_account = |a: &Address| AccountDetails {
@ -491,7 +491,10 @@ impl BlockChainClient for TestBlockChainClient {
balance: balances[a], balance: balances[a],
}; };
self.miner.import_transactions(self, transactions, &fetch_account) self.miner.import_transactions(self, transactions, fetch_account)
.iter()
.map(|res| match res { &Ok(ref t) => Ok(t.clone()), &Err(ref e) => Err(format!("{:?}", e)) })
.collect::<Vec<Result<TransactionImportResult, String>>>()
} }
fn queue_transactions(&self, transactions: Vec<Bytes>) { fn queue_transactions(&self, transactions: Vec<Bytes>) {

View File

@ -18,7 +18,7 @@ use std::mem;
use ipc::binary::BinaryConvertError; use ipc::binary::BinaryConvertError;
use std::collections::VecDeque; use std::collections::VecDeque;
#[derive(Debug, PartialEq)] #[derive(Debug, Clone, PartialEq)]
/// Represents the result of importing transaction. /// Represents the result of importing transaction.
pub enum TransactionImportResult { pub enum TransactionImportResult {
/// Transaction was imported to current queue. /// Transaction was imported to current queue.