mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
🐎 made admin vpass internal
This commit is contained in:
parent
a32efe611f
commit
371cd16e38
2 changed files with 7 additions and 8 deletions
|
|
@ -58,12 +58,10 @@ public:
|
|||
int_fast8_t AdminDelUser(const std::string &name, const std::string &attempt) noexcept;
|
||||
|
||||
bool Contains(const std::string &name) const noexcept;
|
||||
int_fast8_t AdminVerifyPass(const std::string &attempt) noexcept;
|
||||
bool AdminVerifyPass(const std::string &attempt) noexcept; //interall used
|
||||
|
||||
int_fast8_t SetBal(const std::string &name, const std::string &attempt, uint32_t amount) noexcept;
|
||||
|
||||
void Save();
|
||||
void Load();
|
||||
};
|
||||
|
||||
//TODO make branchless
|
||||
|
|
@ -76,8 +76,9 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam
|
|||
if constexpr (max_log_size > 0)
|
||||
{
|
||||
Transaction temp(a_name, b_name, amount);
|
||||
Transaction temp_copy(temp);
|
||||
std::shared_lock<std::shared_mutex> lock{send_funds_l};
|
||||
users.modify_if(a_name, [&temp, &state, amount](User &a) {
|
||||
users.modify_if(a_name, [&temp_copy, &state, amount](User &a) {
|
||||
//if A can afford it
|
||||
if (a.balance < amount)
|
||||
{
|
||||
|
|
@ -86,7 +87,7 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam
|
|||
else
|
||||
{
|
||||
a.balance -= amount;
|
||||
a.log.AddTrans(Transaction(temp));
|
||||
a.log.AddTrans(std::move(temp_copy));
|
||||
state = {k200OK, "Transfer successful!"};
|
||||
}
|
||||
});
|
||||
|
|
@ -253,9 +254,9 @@ bool Bank::Contains(const std::string &name) const noexcept
|
|||
{
|
||||
return users.contains(name);
|
||||
}
|
||||
int_fast8_t Bank::AdminVerifyPass(const std::string &attempt) noexcept
|
||||
bool Bank::AdminVerifyPass(const std::string &attempt) noexcept
|
||||
{
|
||||
return (admin_pass == attempt) ? true : ErrorResponse::WrongPassword;
|
||||
return (admin_pass == attempt);
|
||||
}
|
||||
|
||||
int_fast8_t Bank::SetBal(const std::string &name, const std::string &attempt, uint32_t amount) noexcept
|
||||
|
|
|
|||
Loading…
Reference in a new issue