evaluate.rs
1 // Copyright (c) 2025 ADnet Contributors 2 // This file is part of the AlphaVM library. 3 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at: 7 8 // http://www.apache.org/licenses/LICENSE-2.0 9 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 use super::*; 17 18 impl<N: Network> Process<N> { 19 /// Evaluates a program function on the given request. 20 #[inline] 21 pub fn evaluate<A: circuit::Aleo<Network = N>>(&self, authorization: Authorization<N>) -> Result<Response<N>> { 22 let timer = timer!("Process::evaluate"); 23 24 // Retrieve the top-level request (without popping it). 25 let request = authorization.peek_next()?; 26 27 dev_println!("{}", format!(" • Evaluating '{}/{}'...", request.program_id(), request.function_name())); 28 29 // Retrieve the stack. 30 let stack = self.get_stack(request.program_id())?; 31 // Initialize an RNG. 32 let rng = &mut rand::thread_rng(); 33 // Evaluate the function. 34 let response = stack.evaluate_function::<A, _>(CallStack::evaluate(authorization)?, None, None, rng); 35 lap!(timer, "Evaluate the function"); 36 37 finish!(timer); 38 39 response 40 } 41 }