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

BD-4208 integrate BD-4162 changes into fio.contracts release 2.8.x #285

Merged
merged 1 commit into from
Nov 28, 2022
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
18 changes: 17 additions & 1 deletion contracts/fio.system/src/fio.system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,25 @@ namespace eosiosystem {

auto locks_by_owner = _generallockedtokens.get_index<"byowner"_n>();
auto lockiter = locks_by_owner.find(owner.value);
check(lockiter == locks_by_owner.end(),"cannot emplace locks when locks pre-exist.");
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


Expand Down