From d98e35e0950a695a9332ac3adf519c4c2d0a33e9 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Thu, 20 Sep 2018 14:12:53 -0600 Subject: [PATCH] Delete no longer used PaymentPlan trait --- src/budget.rs | 10 ++++------ src/budget_contract.rs | 2 +- src/payment_plan.rs | 13 ------------- src/transaction.rs | 2 +- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/budget.rs b/src/budget.rs index 0208d0f737..7de861bc5a 100644 --- a/src/budget.rs +++ b/src/budget.rs @@ -4,7 +4,7 @@ //! `Payment`, the payment is executed. use chrono::prelude::*; -use payment_plan::{Payment, PaymentPlan, Witness}; +use payment_plan::{Payment, Witness}; use signature::Pubkey; use std::mem; @@ -75,11 +75,9 @@ impl Budget { (Condition::Signature(from), Payment { tokens, to: from }), ) } -} -impl PaymentPlan for Budget { /// Return Payment if the budget requires no additional Witnesses. - fn final_payment(&self) -> Option { + pub fn final_payment(&self) -> Option { match self { Budget::Pay(payment) => Some(payment.clone()), _ => None, @@ -87,7 +85,7 @@ impl PaymentPlan for Budget { } /// Return true if the budget spends exactly `spendable_tokens`. - fn verify(&self, spendable_tokens: i64) -> bool { + pub fn verify(&self, spendable_tokens: i64) -> bool { match self { Budget::Pay(payment) | Budget::After(_, payment) => payment.tokens == spendable_tokens, Budget::Or(a, b) => a.1.tokens == spendable_tokens && b.1.tokens == spendable_tokens, @@ -96,7 +94,7 @@ impl PaymentPlan for Budget { /// Apply a witness to the budget to see if the budget can be reduced. /// If so, modify the budget in-place. - fn apply_witness(&mut self, witness: &Witness, from: &Pubkey) { + pub fn apply_witness(&mut self, witness: &Witness, from: &Pubkey) { let new_payment = match self { Budget::After(cond, payment) if cond.is_satisfied(witness, from) => Some(payment), Budget::Or((cond, payment), _) if cond.is_satisfied(witness, from) => Some(payment), diff --git a/src/budget_contract.rs b/src/budget_contract.rs index 0b20164036..86776398c1 100644 --- a/src/budget_contract.rs +++ b/src/budget_contract.rs @@ -4,7 +4,7 @@ use bincode::{self, deserialize, serialize_into, serialized_size}; use budget::Budget; use chrono::prelude::{DateTime, Utc}; use instruction::Instruction; -use payment_plan::{PaymentPlan, Witness}; +use payment_plan::Witness; use signature::Pubkey; use std::io; use transaction::Transaction; diff --git a/src/payment_plan.rs b/src/payment_plan.rs index 7fd650d8d8..63d2ded13b 100644 --- a/src/payment_plan.rs +++ b/src/payment_plan.rs @@ -25,16 +25,3 @@ pub struct Payment { /// The `Pubkey` that `tokens` should be paid to. pub to: Pubkey, } - -/// Interface to smart contracts. -pub trait PaymentPlan { - /// Return Payment if the payment plan requires no additional Witnesses. - fn final_payment(&self) -> Option; - - /// Return true if the plan spends exactly `spendable_tokens`. - fn verify(&self, spendable_tokens: i64) -> bool; - - /// Apply a witness to the payment plan to see if the plan can be reduced. - /// If so, modify the plan in-place. - fn apply_witness(&mut self, witness: &Witness, from: &Pubkey); -} diff --git a/src/transaction.rs b/src/transaction.rs index 45d75f4947..e1991d5e8f 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -6,7 +6,7 @@ use budget_contract::BudgetContract; use chrono::prelude::*; use hash::Hash; use instruction::{Contract, Instruction, Vote}; -use payment_plan::{Payment, PaymentPlan}; +use payment_plan::Payment; use signature::{Keypair, KeypairUtil, Pubkey, Signature}; use std::mem::size_of; use system_contract::SystemContract;