Skip to content

Commit

Permalink
Merge pull request #267 from fioprotocol/feature/BD-3941-fiocontacts-…
Browse files Browse the repository at this point in the history
…release28x-07192022

BD-3941. -- address this bug
  • Loading branch information
ericbutz authored Jul 19, 2022
2 parents 42ed021 + 795f682 commit d2a4606
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions contracts/fio.staking/fio.staking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,6 @@ class [[eosio::contract("Staking")]] Staking: public eosio::contract {
int64_t newlockamount = lockiter->lock_amount + (stakingrewardamount + amount);
int64_t newremaininglockamount = lockiter->remaining_lock_amount + (stakingrewardamount + amount);
uint32_t insertperiod = (present_time - lockiter->timestamp) + UNSTAKELOCKDURATIONSECONDS;


uint32_t insertday = (lockiter->timestamp + insertperiod) / SECONDSPERDAY;
uint32_t expirednowduration = present_time - lockiter->timestamp;
uint32_t payouts = lockiter->payouts_performed;
Expand All @@ -445,6 +443,7 @@ class [[eosio::contract("Staking")]] Staking: public eosio::contract {

for (int i = 0; i < lockiter->periods.size(); i++) {
daysforperiod = (lockiter->timestamp + lockiter->periods[i].duration)/SECONDSPERDAY;

uint64_t amountthisperiod = lockiter->periods[i].amount;
//only set the insertindex on the first one greater than or equal that HAS NOT been paid out.
if ((daysforperiod >= insertday) && !foundinsix && (i > (int)lockiter->payouts_performed-1)) {
Expand Down Expand Up @@ -497,12 +496,30 @@ class [[eosio::contract("Staking")]] Staking: public eosio::contract {
}
}

action(
permission_level{get_self(), "active"_n},
SYSTEMACCOUNT,
"modgenlocked"_n,
std::make_tuple(actor, newperiods, newlockamount, newremaininglockamount, payouts)
).send();
//BD-3941 begin, be sure to handle edge case where we have locks and all are in the past.
if (foundinsix) {
action(
permission_level{get_self(), "active"_n},
SYSTEMACCOUNT,
"modgenlocked"_n,
std::make_tuple(actor, newperiods, newlockamount, newremaininglockamount, payouts)
).send();
}else {
//else make the lock as if it was new, ALL perdiods in current locks are in the past!
bool canvote = true;
int64_t lockamount = (int64_t)(stakingrewardamount + amount);

vector <eosiosystem::lockperiodv2> periods;
eosiosystem::lockperiodv2 period;
period.duration = UNSTAKELOCKDURATIONSECONDS;
period.amount = lockamount;
periods.push_back(period);
INLINE_ACTION_SENDER(eosiosystem::system_contract, addgenlocked)
("eosio"_n, {{_self, "active"_n}},
{actor, periods, canvote, lockamount}
);
}
//BD-3941 end
}else {
//else make new lock.
bool canvote = true;
Expand Down

0 comments on commit d2a4606

Please sign in to comment.