Moving own transaction tracing to miner create
This commit is contained in:
parent
8389f771e9
commit
d093c5755e
@ -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> {
|
||||||
|
@ -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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user