Delete no longer used PaymentPlan trait

This commit is contained in:
Greg Fitzgerald 2018-09-20 14:12:53 -06:00
parent 3163fbad0e
commit d98e35e095
4 changed files with 6 additions and 21 deletions

View File

@ -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<Payment> {
pub fn final_payment(&self) -> Option<Payment> {
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),

View File

@ -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;

View File

@ -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<Payment>;
/// 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);
}

View File

@ -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;