From 14ee7b786251e3efc1683d7606c41a2ecbcc09d0 Mon Sep 17 00:00:00 2001 From: Max Conway Date: Fri, 24 Jan 2025 14:16:18 +0000 Subject: [PATCH] Fix for PR comment regarding trace_filter pagination - Moved pagination earlier in the code to avoid unnecessary traces - I've taken a procedural approach here with use of a loop label, but I'm open to switching to iterators --- zilliqa/src/api/trace.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/zilliqa/src/api/trace.rs b/zilliqa/src/api/trace.rs index 39f9acacf..7a6c2f0f8 100644 --- a/zilliqa/src/api/trace.rs +++ b/zilliqa/src/api/trace.rs @@ -200,10 +200,14 @@ fn trace_filter(params: Params, node: &Arc>) -> Result>) -> Result= filter.count.unwrap() { + break 'block_loop; + } + txns_returned_count += 1; + // Create inspector and trace the transaction let config = TracingInspectorConfig::from_parity_config(&trace_types); let mut inspector = TracingInspector::new(config); @@ -267,19 +280,7 @@ fn trace_filter(params: Params, node: &Arc>) -> Result all_traces - .into_iter() - .skip(after as usize) - .take(count as usize) - .collect(), - (Some(after), None) => all_traces.into_iter().skip(after as usize).collect(), - (None, Some(count)) => all_traces.into_iter().take(count as usize).collect(), - (None, None) => all_traces, - }; - - Ok(traces) + Ok(all_traces) } /// trace_rawTransaction