Skip to content

Commit 644abab

Browse files
committed
refactor: adds an early return if the opts is none
1 parent c7b857f commit 644abab

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

crates/rpc/src/debug/endpoints.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ where
3838
Host: FullNodeComponents,
3939
Signet: Pnt,
4040
{
41+
let opts = response_tri!(opts.ok_or(DebugError::from(EthApiError::InvalidTracerConfig)));
42+
4143
let _permit = response_tri!(
4244
ctx.acquire_tracing_permit()
4345
.await
4446
.map_err(|_| DebugError::rpc_error("Failed to acquire tracing permit".into()))
4547
);
4648

4749
let id = id.into();
48-
let span = tracing::debug_span!("traceBlock", ?id, tracer = ?opts.as_ref().and_then(|o| o.tracer.as_ref()));
50+
let span = tracing::debug_span!("traceBlock", ?id, tracer = ?opts.tracer.as_ref());
4951

5052
let fut = async move {
5153
// Fetch the block by ID
@@ -64,8 +66,6 @@ where
6466
let mut trevm = response_tri!(ctx.trevm(crate::LoadState::Before, block.header()));
6567

6668
// Apply all transactions in the block up, tracing each one
67-
let opts = opts.unwrap_or_default();
68-
6969
tracing::trace!(?opts, "Tracing block transactions");
7070

7171
let mut txns = block.body().transactions().enumerate().peekable();
@@ -107,13 +107,15 @@ where
107107
Host: FullNodeComponents,
108108
Signet: Pnt,
109109
{
110+
let opts = response_tri!(opts.ok_or(DebugError::from(EthApiError::InvalidTracerConfig)));
111+
110112
let _permit = response_tri!(
111113
ctx.acquire_tracing_permit()
112114
.await
113115
.map_err(|_| DebugError::rpc_error("Failed to acquire tracing permit".into()))
114116
);
115117

116-
let span = tracing::debug_span!("traceTransaction", %tx_hash, tracer = ?opts.as_ref().and_then(|o| o.tracer.as_ref()));
118+
let span = tracing::debug_span!("traceTransaction", %tx_hash, tracer = ?opts.tracer.as_ref());
117119

118120
let fut = async move {
119121
// Load the transaction by hash
@@ -159,8 +161,7 @@ where
159161
base_fee: block.header().base_fee_per_gas(),
160162
};
161163

162-
let res =
163-
response_tri!(crate::debug::tracer::trace(trevm, &opts.unwrap_or_default(), tx_info)).0;
164+
let res = response_tri!(crate::debug::tracer::trace(trevm, &opts, tx_info)).0;
164165

165166
ResponsePayload::Success(res)
166167
}

0 commit comments

Comments
 (0)