mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
🐛 prune users should return on del if enabled
This commit is contained in:
parent
f48ad92f25
commit
7a0a5d4036
1 changed files with 15 additions and 6 deletions
21
src/bank.cpp
21
src/bank.cpp
|
|
@ -195,15 +195,24 @@ BankResponse Bank::PruneUsers(time_t threshold_time, uint32_t threshold_bal) noe
|
||||||
size_t deleted_count = 0;
|
size_t deleted_count = 0;
|
||||||
for (const auto &u : users)
|
for (const auto &u : users)
|
||||||
{
|
{
|
||||||
if (users.erase_if(u.first, [threshold_time, threshold_bal, &deleted_count](User &u) -> bool
|
#if RETURN_ON_DEL
|
||||||
{
|
uint32_t bal;
|
||||||
#if MAX_LOG_SIZE > 0
|
if (users.erase_if(u.first, [threshold_time, threshold_bal, &bal, &deleted_count](User &u) -> bool {
|
||||||
return ((!u.log.data.size() || u.log.data.back().time < threshold_time) && u.balance < threshold_bal);
|
bal = u.balance;
|
||||||
#else
|
#else
|
||||||
return (u.balance < threshold_bal);
|
if (users.erase_if(u.first, [threshold_time, threshold_bal, &deleted_count](User &u) -> bool {
|
||||||
#endif
|
#endif
|
||||||
}))
|
#if MAX_LOG_SIZE > 0
|
||||||
|
return ((!u.log.data.size() || u.log.data.back().time < threshold_time) && u.balance < threshold_bal);
|
||||||
|
#else
|
||||||
|
return (u.balance < threshold_bal);
|
||||||
|
#endif
|
||||||
|
}))
|
||||||
{
|
{
|
||||||
|
#if RETURN_ON_DEL
|
||||||
|
users.modify_if(return_account, [bal](User &u) { u.balance += bal; });
|
||||||
|
#endif
|
||||||
|
|
||||||
SET_CHANGES_ON;
|
SET_CHANGES_ON;
|
||||||
++deleted_count;
|
++deleted_count;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue