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

Commit

Permalink
Directly return None if tracing is disabled (#8504)
Browse files Browse the repository at this point in the history
* Directly return None if tracing is disabled

* Address gumbles: release read locks as fast as possible
  • Loading branch information
sorpaas authored and 5chdn committed May 1, 2018
1 parent 2a829b1 commit 7a76916
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,10 @@ impl BlockChainClient for Client {
}

fn filter_traces(&self, filter: TraceFilter) -> Option<Vec<LocalizedTrace>> {
if !self.tracedb.read().tracing_enabled() {
return None;
}

let start = self.block_number(filter.range.start)?;
let end = self.block_number(filter.range.end)?;

Expand All @@ -1887,6 +1891,10 @@ impl BlockChainClient for Client {
}

fn trace(&self, trace: TraceId) -> Option<LocalizedTrace> {
if !self.tracedb.read().tracing_enabled() {
return None;
}

let trace_address = trace.address;
self.transaction_address(trace.transaction)
.and_then(|tx_address| {
Expand All @@ -1896,6 +1904,10 @@ impl BlockChainClient for Client {
}

fn transaction_traces(&self, transaction: TransactionId) -> Option<Vec<LocalizedTrace>> {
if !self.tracedb.read().tracing_enabled() {
return None;
}

self.transaction_address(transaction)
.and_then(|tx_address| {
self.block_number(BlockId::Hash(tx_address.block_hash))
Expand All @@ -1904,6 +1916,10 @@ impl BlockChainClient for Client {
}

fn block_traces(&self, block: BlockId) -> Option<Vec<LocalizedTrace>> {
if !self.tracedb.read().tracing_enabled() {
return None;
}

self.block_number(block)
.and_then(|number| self.tracedb.read().block_traces(number))
}
Expand Down

0 comments on commit 7a76916

Please sign in to comment.