modified verification to loop until success or failure
This commit is contained in:
@ -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();
|
||||||
|
Reference in New Issue
Block a user