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