Logging transaction duration (#4297)

* Logging transaction duration

* Printing time also on heavy transactions [ci:skip]
This commit is contained in:
Tomasz Drwięga 2017-01-25 11:02:03 +01:00 committed by Gav Wood
parent 5e18daf29e
commit 67284cc1a2
1 changed files with 3 additions and 1 deletions

View File

@ -573,9 +573,11 @@ fn push_transactions(block: &mut OpenBlock, transactions: &[SignedTransaction])
let start = time::Instant::now();
block.push_transaction(t.clone(), None)?;
let took = start.elapsed();
let took_ms = took.as_secs() * 1000 + took.subsec_nanos() as u64 / 1000000;
if took > time::Duration::from_millis(slow_tx) {
warn!("Heavy transaction in block {:?}: {:?}", block.header().number(), hash);
warn!("Heavy ({} ms) transaction in block {:?}: {:?}", took_ms, block.header().number(), hash);
}
debug!(target: "tx", "Transaction {:?} took: {} ms", hash, took_ms);
}
Ok(())
}