Skip to content

Commit

Permalink
Merge pull request #322 from fioprotocol/develop
Browse files Browse the repository at this point in the history
Merge of bd-4611 staking hotfix into release branch
  • Loading branch information
misterleet authored Jan 22, 2024
2 parents 25c5da4 + 46da7aa commit bf72c8b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions contracts/fio.system/src/fio.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,29 @@ namespace eosiosystem {
check(is_account(owner),"account must pre exist");
check(amount > 0,"cannot add locked token amount less or equal 0.");

//BD-4082 begin
auto locks_by_owner = _generallockedtokens.get_index<"byowner"_n>();
auto lockiter = locks_by_owner.find(owner.value);
bool haslocks = false;
bool allexpired = false;
// BD-4162 begin
if (lockiter != locks_by_owner.end()) {
haslocks = true;
uint32_t present_time = now();
//never clear another accounts stuff. check all locks in the past, remove if they are.
if ((lockiter->owner_account == owner) &&
(((lockiter->periods[lockiter->periods.size() - 1].duration + lockiter->timestamp) < present_time) ||
lockiter->periods.size() == 0)) {
allexpired = true;
locks_by_owner.erase(lockiter);
}
}

//if previous locks and not all expired then error.
check((haslocks && allexpired) || lockiter == locks_by_owner.end(),"cannot emplace locks when locks pre-exist.");
//BD-4162 end
//BD-4082 end

_generallockedtokens.emplace(owner, [&](struct locked_tokens_info_v2 &a) {
a.id = _generallockedtokens.available_primary_key();
a.owner_account = owner;
Expand Down

0 comments on commit bf72c8b

Please sign in to comment.