mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-16 16:12: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;
|
||||
for (const auto &u : users)
|
||||
{
|
||||
if (users.erase_if(u.first, [threshold_time, threshold_bal, &deleted_count](User &u) -> bool
|
||||
{
|
||||
#if MAX_LOG_SIZE > 0
|
||||
return ((!u.log.data.size() || u.log.data.back().time < threshold_time) && u.balance < threshold_bal);
|
||||
#if RETURN_ON_DEL
|
||||
uint32_t bal;
|
||||
if (users.erase_if(u.first, [threshold_time, threshold_bal, &bal, &deleted_count](User &u) -> bool {
|
||||
bal = u.balance;
|
||||
#else
|
||||
return (u.balance < threshold_bal);
|
||||
if (users.erase_if(u.first, [threshold_time, threshold_bal, &deleted_count](User &u) -> bool {
|
||||
#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;
|
||||
++deleted_count;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue