Moving own transaction tracing to miner create

This commit is contained in:
Tomasz Drwięga 2016-04-17 20:36:37 +02:00
parent 8389f771e9
commit d093c5755e
2 changed files with 20 additions and 14 deletions

View File

@ -230,8 +230,23 @@ impl MinerService for Miner {
fn import_own_transaction<T>(&self, transaction: SignedTransaction, fetch_account: T) -> fn import_own_transaction<T>(&self, transaction: SignedTransaction, fetch_account: T) ->
Result<TransactionImportResult, Error> Result<TransactionImportResult, Error>
where T: Fn(&Address) -> AccountDetails { where T: Fn(&Address) -> AccountDetails {
let hash = transaction.hash();
trace!(target: "own_tx", "Importing transaction: {:?}", transaction);
let mut transaction_queue = self.transaction_queue.lock().unwrap(); let mut transaction_queue = self.transaction_queue.lock().unwrap();
transaction_queue.add(transaction, &fetch_account) let import = transaction_queue.add(transaction, &fetch_account);
match import {
Ok(ref res) => {
trace!(target: "own_tx", "Imported transaction to {:?} (hash: {:?})", res, hash);
trace!(target: "own_tx", "Status: {:?}", self.status());
},
Err(ref e) => {
trace!(target: "own_tx", "Failed to import transaction {:?} (hash: {:?})", e, hash);
trace!(target: "own_tx", "Status: {:?}", self.status());
},
}
import
} }
fn pending_transactions_hashes(&self) -> Vec<H256> { fn pending_transactions_hashes(&self) -> Vec<H256> {

View File

@ -182,31 +182,22 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
fn dispatch_transaction(&self, signed_transaction: SignedTransaction) -> Result<Value, Error> { fn dispatch_transaction(&self, signed_transaction: SignedTransaction) -> Result<Value, Error> {
let hash = signed_transaction.hash(); let hash = signed_transaction.hash();
trace!(target: "tx", "Importing transaction: {:?}", signed_transaction); let import = {
let (import, status) = {
let client = take_weak!(self.client); let client = take_weak!(self.client);
let miner = take_weak!(self.miner); let miner = take_weak!(self.miner);
let import = miner.import_own_transaction(signed_transaction, |a: &Address| { miner.import_own_transaction(signed_transaction, |a: &Address| {
AccountDetails { AccountDetails {
nonce: client.nonce(&a), nonce: client.nonce(&a),
balance: client.balance(&a), balance: client.balance(&a),
} }
}); })
let status_after = miner.status();
(import, status_after)
}; };
match import { match import {
Ok(res) => { Ok(_) => to_value(&hash),
trace!(target: "tx", "Imported transaction to {:?} (hash: {:?})", res, hash);
trace!(target: "tx", "Status: {:?}", status);
to_value(&hash)
}
Err(e) => { Err(e) => {
warn!("Error sending transaction: {:?}", e); warn!("Error sending transaction: {:?}", e);
trace!(target: "tx", "Failed to import transaction {:?} (hash: {:?})", e, hash);
trace!(target: "tx", "Status: {:?}", status);
to_value(&H256::zero()) to_value(&H256::zero())
} }
} }