Cleanup naming
This commit is contained in:
parent
f7032f7d9a
commit
4da89ac8a9
|
@ -141,7 +141,7 @@ impl Accountant {
|
|||
}
|
||||
|
||||
let mut plan = tr.plan.clone();
|
||||
plan.process_witness(Witness::Timestamp(self.last_time));
|
||||
plan.apply_witness(Witness::Timestamp(self.last_time));
|
||||
|
||||
if plan.is_complete() {
|
||||
self.complete_transaction(&plan);
|
||||
|
@ -154,7 +154,7 @@ impl Accountant {
|
|||
|
||||
fn process_verified_sig(&mut self, from: PublicKey, tx_sig: Signature) -> Result<()> {
|
||||
let actionable = if let Some(plan) = self.pending.get_mut(&tx_sig) {
|
||||
plan.process_witness(Witness::Signature(from));
|
||||
plan.apply_witness(Witness::Signature(from));
|
||||
plan.is_complete()
|
||||
} else {
|
||||
false
|
||||
|
@ -187,7 +187,7 @@ impl Accountant {
|
|||
// Check to see if any timelocked transactions can be completed.
|
||||
let mut completed = vec![];
|
||||
for (key, plan) in &mut self.pending {
|
||||
plan.process_witness(Witness::Timestamp(self.last_time));
|
||||
plan.apply_witness(Witness::Timestamp(self.last_time));
|
||||
if plan.is_complete() {
|
||||
completed.push(key.clone());
|
||||
}
|
||||
|
|
20
src/plan.rs
20
src/plan.rs
|
@ -19,8 +19,8 @@ pub enum Condition {
|
|||
}
|
||||
|
||||
impl Condition {
|
||||
pub fn is_satisfied(&self, event: &Witness) -> bool {
|
||||
match (self, event) {
|
||||
pub fn is_satisfied(&self, witness: &Witness) -> bool {
|
||||
match (self, witness) {
|
||||
(&Condition::Signature(ref pubkey), &Witness::Signature(ref from)) => pubkey == from,
|
||||
(&Condition::Timestamp(ref dt), &Witness::Timestamp(ref last_time)) => dt <= last_time,
|
||||
_ => false,
|
||||
|
@ -83,19 +83,19 @@ impl Plan {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn process_witness(&mut self, event: Witness) {
|
||||
pub fn apply_witness(&mut self, witness: Witness) {
|
||||
let mut new_payment = None;
|
||||
match *self {
|
||||
Plan::Pay(_) => (),
|
||||
Plan::After(ref cond, ref payment) => {
|
||||
if cond.is_satisfied(&event) {
|
||||
if cond.is_satisfied(&witness) {
|
||||
new_payment = Some(payment.clone());
|
||||
}
|
||||
}
|
||||
Plan::Race(ref a, ref b) => {
|
||||
if a.0.is_satisfied(&event) {
|
||||
if a.0.is_satisfied(&witness) {
|
||||
new_payment = Some(a.1.clone());
|
||||
} else if b.0.is_satisfied(&event) {
|
||||
} else if b.0.is_satisfied(&witness) {
|
||||
new_payment = Some(b.1.clone());
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ mod tests {
|
|||
let to = PublicKey::default();
|
||||
|
||||
let mut plan = Plan::new_authorized_payment(from, 42, to);
|
||||
plan.process_witness(Witness::Signature(from));
|
||||
plan.apply_witness(Witness::Signature(from));
|
||||
assert_eq!(plan, Plan::new_payment(42, to));
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ mod tests {
|
|||
let to = PublicKey::default();
|
||||
|
||||
let mut plan = Plan::new_future_payment(dt, 42, to);
|
||||
plan.process_witness(Witness::Timestamp(dt));
|
||||
plan.apply_witness(Witness::Timestamp(dt));
|
||||
assert_eq!(plan, Plan::new_payment(42, to));
|
||||
}
|
||||
|
||||
|
@ -164,11 +164,11 @@ mod tests {
|
|||
let to = PublicKey::default();
|
||||
|
||||
let mut plan = Plan::new_cancelable_future_payment(dt, from, 42, to);
|
||||
plan.process_witness(Witness::Timestamp(dt));
|
||||
plan.apply_witness(Witness::Timestamp(dt));
|
||||
assert_eq!(plan, Plan::new_payment(42, to));
|
||||
|
||||
let mut plan = Plan::new_cancelable_future_payment(dt, from, 42, to);
|
||||
plan.process_witness(Witness::Signature(from));
|
||||
plan.apply_witness(Witness::Signature(from));
|
||||
assert_eq!(plan, Plan::new_payment(42, from));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue