//claim rewards
function claim() public only_staker
{
if (CS_frozen) return; //Don't pay rewards when Cold Staking frozen.
new_block(); //run once per block
uint _StakingInterval = Timestamp.sub(staker[msg.sender].time); //time interval of deposit.
if (_StakingInterval >= round_interval)
{
uint _CompleteRoundsInterval = (_StakingInterval / round_interval).mul(round_interval); //only complete rounds.
uint _StakerWeight = _CompleteRoundsInterval.mul(staker[msg.sender].amount); //Weight of completed rounds.
uint _reward = StakingRewardPool.mul(_StakerWeight).div(TotalStakingWeight); //StakingRewardPool * _StakerWeight/TotalStakingWeight
StakingRewardPool = StakingRewardPool.sub(_reward);
TotalStakingWeight = TotalStakingWeight.sub(_StakerWeight); // remove paid Weight.
staker[msg.sender].time = staker[msg.sender].time.add(_CompleteRoundsInterval); // reset to paid time, staking continue without a loss of incomplete rounds.
msg.sender.transfer(_reward);
emit Claim(msg.sender, _reward);
}
}