Cleanup: replace bool retval with is_complete() method

This commit is contained in:
Greg Fitzgerald
2018-03-20 16:52:47 -06:00
parent 7c7e3931a0
commit f7032f7d9a
2 changed files with 21 additions and 15 deletions

View File

@@ -141,20 +141,21 @@ impl Accountant {
}
let mut plan = tr.plan.clone();
let actionable = plan.process_witness(Witness::Timestamp(self.last_time));
plan.process_witness(Witness::Timestamp(self.last_time));
if !actionable {
if plan.is_complete() {
self.complete_transaction(&plan);
} else {
self.pending.insert(tr.sig, plan);
return Ok(());
}
self.complete_transaction(&plan);
Ok(())
}
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.process_witness(Witness::Signature(from));
plan.is_complete()
} else {
false
};
@@ -186,7 +187,8 @@ impl Accountant {
// Check to see if any timelocked transactions can be completed.
let mut completed = vec![];
for (key, plan) in &mut self.pending {
if plan.process_witness(Witness::Timestamp(self.last_time)) {
plan.process_witness(Witness::Timestamp(self.last_time));
if plan.is_complete() {
completed.push(key.clone());
}
}