Skip to content

Commit

Permalink
process subcalls in the exact orders they were called
Browse files Browse the repository at this point in the history
  • Loading branch information
sunce86 committed Jan 21, 2025
1 parent 4f3da4f commit e0c7919
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/autopilot/src/domain/settlement/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,16 @@ fn find_settlement_trace(
call_frame: &eth::CallFrame,
settlement_contract: eth::Address,
) -> Option<&eth::CallFrame> {
// Use a stack to keep track of frames to process
let mut stack = vec![call_frame];
// Use a queue (VecDeque) to keep track of frames to process
let mut queue = std::collections::VecDeque::new();
queue.push_back(call_frame);

while let Some(call_frame) = stack.pop() {
while let Some(call_frame) = queue.pop_front() {
if is_settlement_trace(call_frame, settlement_contract) {
return Some(call_frame);
}
// Add all nested calls to the stack
stack.extend(&call_frame.calls);
// Add all nested calls to the queue
queue.extend(&call_frame.calls);
}

None
Expand Down

0 comments on commit e0c7919

Please sign in to comment.