Struct miden_core::mast::SplitNode
source · pub struct SplitNode { /* private fields */ }Expand description
A Split node defines conditional execution. When the VM encounters a Split node it executes
either the on_true child or on_false child.
Which child is executed is determined based on the top of the stack. If the value is 1, then
the on_true child is executed. If the value is 0, then the on_false child is executed. If
the value is neither 0 nor 1, the execution fails.
Implementations§
source§impl SplitNode
impl SplitNode
Constructors
pub fn new( branches: [MastNodeId; 2], mast_forest: &MastForest, ) -> Result<Self, MastForestError>
sourcepub fn new_unsafe(branches: [MastNodeId; 2], digest: RpoDigest) -> Self
pub fn new_unsafe(branches: [MastNodeId; 2], digest: RpoDigest) -> Self
Returns a new SplitNode from values that are assumed to be correct.
Should only be used when the source of the inputs is trusted (e.g. deserialization).
source§impl SplitNode
impl SplitNode
Public accessors
sourcepub fn digest(&self) -> RpoDigest
pub fn digest(&self) -> RpoDigest
Returns a commitment to this Split node.
The commitment is computed as a hash of the on_true and on_false child nodes in the
domain defined by Self::DOMAIN - i..e,:
Hasher::merge_in_domain(&[on_true_digest, on_false_digest], SplitNode::DOMAIN);sourcepub fn on_true(&self) -> MastNodeId
pub fn on_true(&self) -> MastNodeId
Returns the ID of the node which is to be executed if the top of the stack is 1.
sourcepub fn on_false(&self) -> MastNodeId
pub fn on_false(&self) -> MastNodeId
Returns the ID of the node which is to be executed if the top of the stack is 0.
Trait Implementations§
impl Eq for SplitNode
impl StructuralPartialEq for SplitNode
Auto Trait Implementations§
impl Freeze for SplitNode
impl RefUnwindSafe for SplitNode
impl Send for SplitNode
impl Sync for SplitNode
impl Unpin for SplitNode
impl UnwindSafe for SplitNode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)