modified verification to loop until success or failure

This commit is contained in:
Robert Kelly
2018-05-02 10:15:08 -04:00
parent cb362e9052
commit b992a84d67

View File

@ -24,7 +24,6 @@ pub const MAX_ENTRY_IDS: usize = 1024 * 4;
#[derive(Debug, PartialEq, Eq)]
pub enum AccountingError {
AccountNotFound,
BalanceUpdatedBeforeTransactionCompleted,
InsufficientFunds,
InvalidTransferSignature,
}
@ -142,6 +141,7 @@ impl Accountant {
return Err(AccountingError::InvalidTransferSignature);
}
loop {
let bal = option.unwrap();
let current = bal.load(Ordering::Relaxed) as i64;
@ -157,11 +157,12 @@ impl Accountant {
Ordering::Relaxed,
);
return match result {
Ok(_) => Ok(()),
Err(_) => Err(AccountingError::BalanceUpdatedBeforeTransactionCompleted),
match result {
Ok(_) => return Ok(()),
Err(_) => continue,
};
}
}
pub fn process_verified_transaction_credits(&self, tr: &Transaction) {
let mut plan = tr.data.plan.clone();