Skip to content

Commit

Permalink
Sample ExternalRecord in sample_value
Browse files Browse the repository at this point in the history
  • Loading branch information
vicsn committed Dec 28, 2023
1 parent c2acc5f commit a9f3483
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
22 changes: 2 additions & 20 deletions synthesizer/process/src/stack/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{
stack::{
Address,
ValueType::{ExternalRecord, Record},
},
CallStack,
Registers,
RegistersCall,
StackEvaluate,
StackExecute,
};
use crate::{stack::Address, CallStack, Registers, RegistersCall, StackEvaluate, StackExecute};
use aleo_std::prelude::{finish, lap, timer};
use console::{network::prelude::*, program::Request};
use synthesizer_program::{
Expand Down Expand Up @@ -291,15 +281,7 @@ impl<N: Network> CallTrait<N> for Call<N> {
let outputs = function
.outputs()
.iter()
.map(|output| match output.value_type() {
ExternalRecord(locator) => {
// Retrieve the external stack.
let stack = substack.get_external_stack(locator.program_id())?;
// Sample the output.
stack.sample_value(&address, &Record(*locator.resource()), rng)
}
_ => substack.sample_value(&address, output.value_type(), rng),
})
.map(|output| substack.sample_value(&address, output.value_type(), rng))
.collect::<Result<Vec<_>>>()?;

// Retrieve the output operands.
Expand Down
5 changes: 4 additions & 1 deletion synthesizer/process/src/stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ impl<N: Network> StackProgram<N> for Stack<N> {
Ok(Value::Record(self.sample_record(burner_address, record_name, rng)?))
}
ValueType::ExternalRecord(locator) => {
bail!("Illegal operation: Cannot sample external records (for '{locator}.record').")
// Retrieve the external stack.
let stack = self.get_external_stack(locator.program_id())?;
// Sample the output.
Ok(Value::Record(stack.sample_record(burner_address, locator.resource(), rng)?))
}
ValueType::Future(locator) => Ok(Value::Future(self.sample_future(locator, rng)?)),
}
Expand Down

0 comments on commit a9f3483

Please sign in to comment.