From d093c5755e0b65e59144b3ddf4296fdd9385e504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sun, 17 Apr 2016 20:36:37 +0200 Subject: [PATCH] Moving own transaction tracing to miner create --- miner/src/miner.rs | 17 ++++++++++++++++- rpc/src/v1/impls/eth.rs | 17 ++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/miner/src/miner.rs b/miner/src/miner.rs index 29055713d..287250f04 100644 --- a/miner/src/miner.rs +++ b/miner/src/miner.rs @@ -230,8 +230,23 @@ impl MinerService for Miner { fn import_own_transaction(&self, transaction: SignedTransaction, fetch_account: T) -> Result 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(); - 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 { diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index 553c8201c..303486bfa 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -182,31 +182,22 @@ impl EthClient fn dispatch_transaction(&self, signed_transaction: SignedTransaction) -> Result { let hash = signed_transaction.hash(); - trace!(target: "tx", "Importing transaction: {:?}", signed_transaction); - let (import, status) = { + let import = { let client = take_weak!(self.client); 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 { nonce: client.nonce(&a), balance: client.balance(&a), } - }); - let status_after = miner.status(); - (import, status_after) + }) }; match import { - Ok(res) => { - trace!(target: "tx", "Imported transaction to {:?} (hash: {:?})", res, hash); - trace!(target: "tx", "Status: {:?}", status); - to_value(&hash) - } + Ok(_) => to_value(&hash), Err(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()) } }