Skip to content

Commit

Permalink
Race -> Or
Browse files Browse the repository at this point in the history
Thanks for the suggestion @FishmanL!
  • Loading branch information
garious committed Jun 7, 2018
1 parent c2a9395 commit fe7d1cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/budget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum Budget {

/// Either make a payment after one condition or a different payment after another
/// condition, which ever condition is satisfied first.
Race((Condition, Payment), (Condition, Payment)),
Or((Condition, Payment), (Condition, Payment)),
}

impl Budget {
Expand All @@ -68,7 +68,7 @@ impl Budget {
tokens: i64,
to: PublicKey,
) -> Self {
Budget::Race(
Budget::Or(
(Condition::Timestamp(dt), Payment { tokens, to }),
(Condition::Signature(from), Payment { tokens, to: from }),
)
Expand All @@ -88,7 +88,7 @@ impl PaymentPlan for Budget {
fn verify(&self, spendable_tokens: i64) -> bool {
match self {
Budget::Pay(payment) | Budget::After(_, payment) => payment.tokens == spendable_tokens,
Budget::Race(a, b) => a.1.tokens == spendable_tokens && b.1.tokens == spendable_tokens,
Budget::Or(a, b) => a.1.tokens == spendable_tokens && b.1.tokens == spendable_tokens,
}
}

Expand All @@ -97,8 +97,8 @@ impl PaymentPlan for Budget {
fn apply_witness(&mut self, witness: &Witness) {
let new_payment = match self {
Budget::After(cond, payment) if cond.is_satisfied(witness) => Some(payment),
Budget::Race((cond, payment), _) if cond.is_satisfied(witness) => Some(payment),
Budget::Race(_, (cond, payment)) if cond.is_satisfied(witness) => Some(payment),
Budget::Or((cond, payment), _) if cond.is_satisfied(witness) => Some(payment),
Budget::Or(_, (cond, payment)) if cond.is_satisfied(witness) => Some(payment),
_ => None,
}.cloned();

Expand Down
2 changes: 1 addition & 1 deletion src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Transaction {
last_id: Hash,
) -> Self {
let from = from_keypair.pubkey();
let budget = Budget::Race(
let budget = Budget::Or(
(Condition::Timestamp(dt), Payment { tokens, to }),
(Condition::Signature(from), Payment { tokens, to: from }),
);
Expand Down

0 comments on commit fe7d1cb

Please sign in to comment.