mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 08:32:13 +11:00
GetLogs() func doesnt compile when toggled off
This commit is contained in:
parent
b60b6293aa
commit
c7e2794e56
2 changed files with 10 additions and 8 deletions
|
|
@ -48,7 +48,9 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BankResponse GetBal(const std::string &name) const noexcept;
|
BankResponse GetBal(const std::string &name) const noexcept;
|
||||||
|
#if MAX_LOG_SIZE > 0
|
||||||
BankResponse GetLogs(const std::string &name) noexcept;
|
BankResponse GetLogs(const std::string &name) noexcept;
|
||||||
|
#endif
|
||||||
BankResponse SendFunds(const std::string &a_name, const std::string &b_name, uint32_t amount) noexcept;
|
BankResponse SendFunds(const std::string &a_name, const std::string &b_name, uint32_t amount) noexcept;
|
||||||
bool VerifyPassword(const std::string &name, std::string_view &&attempt) const noexcept;
|
bool VerifyPassword(const std::string &name, std::string_view &&attempt) const noexcept;
|
||||||
|
|
||||||
|
|
|
||||||
16
src/bank.cpp
16
src/bank.cpp
|
|
@ -69,17 +69,17 @@ BankResponse Bank::GetBal(const std::string &name) const noexcept
|
||||||
users.if_contains(name, [](const User &u) { res = u.balance + 1; });
|
users.if_contains(name, [](const User &u) { res = u.balance + 1; });
|
||||||
return res ? BankResponse(k200OK, std::to_string(res - 1)) : BankResponse(k404NotFound, "\"User not found\"");
|
return res ? BankResponse(k200OK, std::to_string(res - 1)) : BankResponse(k404NotFound, "\"User not found\"");
|
||||||
}
|
}
|
||||||
|
#if MAX_LOG_SIZE > 0
|
||||||
BankResponse Bank::GetLogs(const std::string &name) noexcept
|
BankResponse Bank::GetLogs(const std::string &name) noexcept
|
||||||
{
|
{
|
||||||
#if MAX_LOG_SIZE > 0
|
|
||||||
BankResponse res;
|
BankResponse res;
|
||||||
if (!users.modify_if(name, [&res](User &u) { res = BankResponse(k200OK, u.log.GetLog()); }))
|
if (!users.modify_if(name, [&res](User &u) { res = BankResponse(k200OK, u.log.GetLogs()); }))
|
||||||
{
|
{
|
||||||
return BankResponse(k404NotFound, "\"User not found\"");
|
return BankResponse(k404NotFound, "\"User not found\"");
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_name, uint32_t amount) noexcept
|
BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_name, uint32_t amount) noexcept
|
||||||
{
|
{
|
||||||
//cant send money to self, from self or amount is 0
|
//cant send money to self, from self or amount is 0
|
||||||
|
|
@ -119,7 +119,7 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam
|
||||||
#if MAX_LOG_SIZE > 0
|
#if MAX_LOG_SIZE > 0
|
||||||
a.log.AddTrans(Transaction(temp)); //about 40% of this function's cost
|
a.log.AddTrans(Transaction(temp)); //about 40% of this function's cost
|
||||||
#endif
|
#endif
|
||||||
state = BankResponse(k200OK, "\"Transfer successful!\"");
|
state = BankResponse(k200OK, "true");
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
|
|
@ -174,7 +174,7 @@ BankResponse Bank::SetBal(const std::string &name, uint32_t amount) noexcept
|
||||||
save_flag = true;
|
save_flag = true;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return {k200OK, "\"Balance set!\""};
|
return {k200OK, "true"};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -196,7 +196,7 @@ BankResponse Bank::ImpactBal(const std::string &name, int64_t amount) noexcept
|
||||||
save_flag = true;
|
save_flag = true;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return {k200OK, "\"Balance added!\""};
|
return {k200OK, "true"};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -229,7 +229,7 @@ BankResponse Bank::AddUser(std::string &&name, uint32_t init_bal, std::string &&
|
||||||
save_flag = true;
|
save_flag = true;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return {k200OK, "\"User added!\""};
|
return {k200OK, "true"};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -259,7 +259,7 @@ BankResponse Bank::DelUser(const std::string &name) noexcept
|
||||||
save_flag = true;
|
save_flag = true;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return BankResponse(k200OK, "\"User deleted!\"");
|
return BankResponse(k200OK, "true");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue