pub fn apply_witness(&mut self, witness: &Witness, from: &Pubkey) {
        let new_expr = match self {
            BudgetExpr::After(cond, payment) if cond.is_satisfied(witness, from) => {
                Some(BudgetExpr::Pay(payment.clone()))
            }
            BudgetExpr::Or((cond, payment), _) if cond.is_satisfied(witness, from) => {
                Some(BudgetExpr::Pay(payment.clone()))
            }
            BudgetExpr::Or(_, (cond, payment)) if cond.is_satisfied(witness, from) => {
                Some(BudgetExpr::Pay(payment.clone()))
            }
            BudgetExpr::And(cond0, cond1, payment) => {
                if cond0.is_satisfied(witness, from) {
                    Some(BudgetExpr::After(cond1.clone(), payment.clone()))
                } else if cond1.is_satisfied(witness, from) {
                    Some(BudgetExpr::After(cond0.clone(), payment.clone()))
                } else {
                    None
                }
            }
            _ => None,
        };
        if let Some(expr) = new_expr {
            mem::replace(self, expr);
        }
    }
/// Apply a witness to the budget to see if the budget can be reduced.
/// If so, modify the budget in-place.
Apply a witness to the budget to see if the budget can be reduced.
If so, modify the budget in-place.
Apply a witness to the budget to see if the budget can be reduced . If so modify the budget in - place .
pub fn apply_witness(&mut self, witness: &Witness, from: &Pubkey) {
        let new_expr = match self {
            BudgetExpr::After(cond, payment) if cond.is_satisfied(witness, from) => {
                Some(BudgetExpr::Pay(payment.clone()))
            }
            BudgetExpr::Or((cond, payment), _) if cond.is_satisfied(witness, from) => {
                Some(BudgetExpr::Pay(payment.clone()))
            }
            BudgetExpr::Or(_, (cond, payment)) if cond.is_satisfied(witness, from) => {
                Some(BudgetExpr::Pay(payment.clone()))
            }
            BudgetExpr::And(cond0, cond1, payment) => {
                if cond0.is_satisfied(witness, from) {
                    Some(BudgetExpr::After(cond1.clone(), payment.clone()))
                } else if cond1.is_satisfied(witness, from) {
                    Some(BudgetExpr::After(cond0.clone(), payment.clone()))
                } else {
                    None
                }
            }
            _ => None,
        };
        if let Some(expr) = new_expr {
            mem::replace(self, expr);
        }
    }
pub fn apply_witness ( & mut self , witness : & Witness , from : & Pubkey ) { let new_expr = match self { BudgetExpr :: After ( cond , payment ) if cond . is_satisfied ( witness , from ) => { Some ( BudgetExpr :: Pay ( payment . clone ( ) ) ) } BudgetExpr :: Or ( ( cond , payment ) , _ ) if cond . is_satisfied ( witness , from ) => { Some ( BudgetExpr :: Pay ( payment . clone ( ) ) ) } BudgetExpr :: Or ( _ , ( cond , payment ) ) if cond . is_satisfied ( witness , from ) => { Some ( BudgetExpr :: Pay ( payment . clone ( ) ) ) } BudgetExpr :: And ( cond0 , cond1 , payment ) => { if cond0 . is_satisfied ( witness , from ) { Some ( BudgetExpr :: After ( cond1 . clone ( ) , payment . clone ( ) ) ) } else if cond1 . is_satisfied ( witness , from ) { Some ( BudgetExpr :: After ( cond0 . clone ( ) , payment . clone ( ) ) ) } else { None } } _ => None , } ; if let Some ( expr ) = new_expr { mem :: replace ( self , expr ) ; } }
Apply a witness to the budget to see if the budget can be reduced.
Apply a witness to the budget to see if the budget can be reduced .
&mut self
witness
&Witness
from
&Pubkey
&mut self
witness
&Witness
from
&Pubkey