Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Additional logging for own transactions in queue (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw authored and gavofyork committed Jun 18, 2016
1 parent 16412eb commit fa65d63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl MinerService for Miner {
Result<TransactionImportResult, Error>
where T: Fn(&Address) -> AccountDetails {
let hash = transaction.hash();
trace!(target: "own_tx", "Importing transaction: {:?}", transaction);
debug!(target: "own_tx", "Importing transaction: {:?}", transaction);

let imported = {
// Be sure to release the lock before we call enable_and_prepare_sealing
Expand All @@ -397,11 +397,11 @@ impl MinerService for Miner {

match import {
Ok(ref res) => {
trace!(target: "own_tx", "Imported transaction to {:?} (hash: {:?})", res, hash);
debug!(target: "own_tx", "Imported transaction to {:?} (hash: {:?})", res, hash);
trace!(target: "own_tx", "Status: {:?}", transaction_queue.status());
},
Err(ref e) => {
trace!(target: "own_tx", "Failed to import transaction {:?} (hash: {:?})", e, hash);
debug!(target: "own_tx", "Failed to import transaction {:?} (hash: {:?})", e, hash);
trace!(target: "own_tx", "Status: {:?}", transaction_queue.status());
warn!(target: "own_tx", "Error importing transaction: {:?}", e);
},
Expand Down
22 changes: 20 additions & 2 deletions ethcore/src/miner/transaction_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ impl Ord for TransactionOrigin {
}
}

macro_rules! trace_local {
($order: expr, $x: expr) => {
if $order.origin == TransactionOrigin::Local {
$x
}
}
}

#[derive(Clone, Debug)]
/// Light structure used to identify transaction and it's order
struct TransactionOrder {
Expand Down Expand Up @@ -255,8 +263,11 @@ impl TransactionSet {
self.by_priority
.iter()
.skip(self.limit)
.map(|order| by_hash.get(&order.hash)
.expect("All transactions in `self.by_priority` and `self.by_address` are kept in sync with `by_hash`."))
.map(|order| {
trace_local!(order, trace!(target: "own_tx", "Removing transaction because of limit {:?}", order.hash));
trace!(target: "miner", "Removing transaction because of limit {:?}", order.hash);
by_hash.get(&order.hash).expect("All transactions in `self.by_priority` and `self.by_address` are kept in sync with `by_hash`.")
})
.map(|tx| (tx.sender(), tx.nonce()))
.collect()
};
Expand Down Expand Up @@ -541,8 +552,10 @@ impl TransactionQueue {
for k in all_nonces_from_sender {
let order = self.future.drop(sender, &k).unwrap();
if k >= current_nonce {
trace_local!(order, trace!(target: "own_tx", "Moving transaction to future {:?} (nonce: {} >= {})", order.hash, k, current_nonce));
self.future.insert(*sender, k, order.update_height(k, current_nonce));
} else {
trace_local!(order, trace!(target: "own_tx", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce));
trace!(target: "miner", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce);
// Remove the transaction completely
self.by_hash.remove(&order.hash);
Expand All @@ -562,8 +575,10 @@ impl TransactionQueue {
// Goes to future or is removed
let order = self.current.drop(sender, &k).unwrap();
if k >= current_nonce {
trace_local!(order, trace!(target: "own_tx", "Moving transaction to future {:?} (nonce: {} >= {})", order.hash, k, current_nonce));
self.future.insert(*sender, k, order.update_height(k, current_nonce));
} else {
trace_local!(order, trace!(target: "own_tx", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce));
trace!(target: "miner", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce);
self.by_hash.remove(&order.hash);
}
Expand Down Expand Up @@ -622,6 +637,9 @@ impl TransactionQueue {
}
let mut by_nonce = by_nonce.unwrap();
while let Some(order) = by_nonce.remove(&current_nonce) {
trace_local!(order, trace!(
target: "own_tx", "Moving transaction back to current: {:?} ({} <= {})", order.hash, first_nonce, current_nonce
));
// remove also from priority and hash
self.future.by_priority.remove(&order);
// Put to current
Expand Down

0 comments on commit fa65d63

Please sign in to comment.