Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/creditor balance #13

Merged
merged 2 commits into from
Oct 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ namespace utils
{
auto symbol = symbol_type(system_token_symbol);
eosio::token t(N(eosio.token));
return t.get_balance(owner, symbol.name());
auto balance = t.get_balance(owner, symbol.name());
// update creditor if balance is outdated
creditor_table c(code_account, SCOPE_CREDITOR>>1);
auto creditor_itr = c.find(owner);
if(creditor_itr->balance != balance) {
c.modify(creditor_itr, ram_payer, [&](auto &i) {
i.balance = balance;
i.updated_at = now();
});
}
return balance;
}

//rotate active creditor
Expand All @@ -59,7 +69,7 @@ namespace utils
auto idx = c.get_index<N(updated_at)>();
auto itr = idx.begin();
asset free_balance = get_balance(free_creditor);
asset paid_balance = get_balance(free_creditor);
asset paid_balance = get_balance(paid_creditor);
auto free_rotated = free_balance.amount > MIN_CREDITOR_BALANCE ?TRUE:FALSE;
auto paid_rotated = paid_balance.amount > MIN_CREDITOR_BALANCE ?TRUE:FALSE;

Expand Down