Skip to content

Commit

Permalink
Merge pull request #15 from devintegral3/feature/calc_rewards_check
Browse files Browse the repository at this point in the history
Read-only calls calcRewards check lowest payable epoch
  • Loading branch information
devintegral3 committed Feb 11, 2020
2 parents 23945e5 + f6d6d3b commit 481a758
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/sfc/Staker.sol
Expand Up @@ -374,6 +374,10 @@ contract Stakers is Ownable, StakersConstants {
uint256 fromEpoch = withDefault(_fromEpoch, delegations[delegator].paidUntilEpoch + 1);
assert(delegations[delegator].deactivatedTime == 0);

if (delegations[delegator].paidUntilEpoch >= fromEpoch) {
return (0, fromEpoch, 0);
}

uint256 pendingRewards = 0;
uint256 lastEpoch = 0;
for (uint256 e = fromEpoch; e <= currentSealedEpoch && e < fromEpoch + maxEpochs; e++) {
Expand All @@ -389,6 +393,10 @@ contract Stakers is Ownable, StakersConstants {
function calcValidatorRewards(uint256 stakerID, uint256 _fromEpoch, uint256 maxEpochs) public view returns (uint256, uint256, uint256) {
uint256 fromEpoch = withDefault(_fromEpoch, stakers[stakerID].paidUntilEpoch + 1);

if (stakers[stakerID].paidUntilEpoch >= fromEpoch) {
return (0, fromEpoch, 0);
}

uint256 pendingRewards = 0;
uint256 lastEpoch = 0;
for (uint256 e = fromEpoch; e <= currentSealedEpoch && e < fromEpoch + maxEpochs; e++) {
Expand Down

0 comments on commit 481a758

Please sign in to comment.