mirror of
https://github.com/Expand-sys/CCash
synced 2026-03-22 12:37:08 +11:00
changed order of conditional
This commit is contained in:
parent
31e08aeb97
commit
a08d53bf34
1 changed files with 8 additions and 8 deletions
16
src/bank.cpp
16
src/bank.cpp
|
|
@ -117,18 +117,11 @@ int_fast8_t Bank::SendFunds(const std::string &a_name, const std::string &b_name
|
|||
{
|
||||
Transaction temp;
|
||||
//if B does exist
|
||||
if (users.modify_if(b_name, [&a_name, &b_name, &temp, amount](User &b) {
|
||||
if (!users.modify_if(b_name, [&a_name, &b_name, &temp, amount](User &b) {
|
||||
temp = Transaction(a_name, b_name, amount);
|
||||
b.balance += amount;
|
||||
b.log.AddTrans(std::forward<Transaction>(temp));
|
||||
}))
|
||||
{
|
||||
users.modify_if(a_name, [&temp](User &a) {
|
||||
a.log.AddTrans(std::move(temp));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//attempt to refund if A exist
|
||||
users.modify_if(a_name, [amount](User &a) {
|
||||
|
|
@ -136,6 +129,13 @@ int_fast8_t Bank::SendFunds(const std::string &a_name, const std::string &b_name
|
|||
});
|
||||
return ErrorResponse::UserNotFound; //because had to refund transaction
|
||||
}
|
||||
else
|
||||
{
|
||||
users.modify_if(a_name, [&temp](User &a) {
|
||||
a.log.AddTrans(std::move(temp));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue