Skip to main content

apply

Function apply 

Source
pub fn apply(
    op_log: &OpLog,
    head_op: Option<&OpId>,
    op: Operation,
    transition: StageTransition,
) -> Result<NewHead, ApplyError>
Expand description

Apply an operation against a branch head and persist it.

Validates parents:

  • If op.parents.is_empty(): head_op must be None (genesis op on an empty branch).
  • If op.parents.len() == 1: that parent must equal head_op.
  • If op.parents.len() == 2: one parent must equal head_op, and the other must already exist in the log (a merge op’s second-parent ancestry must be reachable).
  • All other arities are rejected as StaleParent.