mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 16:18:08 -05:00
fix(rpc-trace): add after and count to trace_filter (#9662)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -251,7 +251,7 @@ where
|
||||
filter: TraceFilter,
|
||||
) -> EthResult<Vec<LocalizedTransactionTrace>> {
|
||||
let matcher = filter.matcher();
|
||||
let TraceFilter { from_block, to_block, .. } = filter;
|
||||
let TraceFilter { from_block, to_block, after, count, .. } = filter;
|
||||
let start = from_block.unwrap_or(0);
|
||||
let end = if let Some(to_block) = to_block {
|
||||
to_block
|
||||
@@ -341,6 +341,20 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// apply after and count to traces if specified, this allows for a pagination style.
|
||||
// only consider traces after
|
||||
if let Some(after) = after.map(|a| a as usize).filter(|a| *a < all_traces.len()) {
|
||||
all_traces = all_traces.split_off(after);
|
||||
}
|
||||
|
||||
// at most, return count of traces
|
||||
if let Some(count) = count {
|
||||
let count = count as usize;
|
||||
if count < all_traces.len() {
|
||||
all_traces.truncate(count);
|
||||
}
|
||||
};
|
||||
|
||||
Ok(all_traces)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user