From aba1d844f806c6d174ad2b8899d4639a8c8a4840 Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Thu, 27 Nov 2025 10:42:58 -0300 Subject: [PATCH] consume call stack from the other end --- nssa/src/public_transaction/transaction.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nssa/src/public_transaction/transaction.rs b/nssa/src/public_transaction/transaction.rs index a399ad3..af07895 100644 --- a/nssa/src/public_transaction/transaction.rs +++ b/nssa/src/public_transaction/transaction.rs @@ -1,4 +1,4 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::{HashMap, HashSet, VecDeque}; use nssa_core::{ account::{Account, AccountId, AccountWithMetadata}, @@ -108,10 +108,10 @@ impl PublicTransaction { pre_states: input_pre_states, }; - let mut chained_calls = Vec::from_iter([initial_call]); + let mut chained_calls = VecDeque::from_iter([initial_call]); let mut chain_calls_counter = 0; - while let Some(chained_call) = chained_calls.pop() { + while let Some(chained_call) = chained_calls.pop_front() { if chain_calls_counter > MAX_NUMBER_CHAINED_CALLS { return Err(NssaError::MaxChainedCallsDepthExceeded); } @@ -168,7 +168,7 @@ impl PublicTransaction { state_diff.insert(pre.account_id, post.clone()); } - chained_calls.extend_from_slice(&program_output.chained_calls); + chained_calls.extend(program_output.chained_calls); chain_calls_counter += 1; }