Skip to content

Commit

Permalink
fix(rpc/trace): return empty if after >= traces (paradigmxyz#11715)
Browse files Browse the repository at this point in the history
Signed-off-by: jsvisa <[email protected]>
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
jsvisa and mattsse authored Oct 14, 2024
1 parent 600a394 commit 9f9de0f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crates/rpc/rpc/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,18 @@ 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);
// Skips the first `after` number of matching traces.
// If `after` is greater than or equal to the number of matched traces, it returns an empty
// array.
if let Some(after) = after.map(|a| a as usize) {
if after < all_traces.len() {
all_traces.drain(..after);
} else {
return Ok(vec![])
}
}

// at most, return count of traces
// Return at most `count` of traces
if let Some(count) = count {
let count = count as usize;
if count < all_traces.len() {
Expand Down

0 comments on commit 9f9de0f

Please sign in to comment.