Skip to content

Commit

Permalink
Merge pull request #952 from iotaledger/fix/rewards-rollback
Browse files Browse the repository at this point in the history
Fixed prunable rollback deleting the rewards
  • Loading branch information
alexsporn authored May 2, 2024
2 parents 7f81e70 + 7b3b4fe commit e0a3fef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/storage/prunable/prunable.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,13 @@ func (p *Prunable) Rollback(targetEpoch iotago.EpochIndex, startPruneRange iotag
return ierrors.Wrapf(err, "failed to rollback decided upgrade signals epochs to target epoch %d", targetEpoch)
}

lastPrunedPoolRewardsEpoch, err := p.poolRewards.RollbackEpochs(targetEpoch)
if err != nil {
return ierrors.Wrapf(err, "failed to rollback pool rewards epochs to target epoch %d", targetEpoch)
var lastPrunedPoolRewardsEpoch iotago.EpochIndex
// Do not rollback the epoch if the targetSlot is the end of the epoch, because that is when we calculated the rewards.
if targetSlot := startPruneRange - 1; p.apiProvider.APIForSlot(targetSlot).TimeProvider().EpochEnd(targetEpoch) != targetSlot {
lastPrunedPoolRewardsEpoch, err = p.poolRewards.RollbackEpochs(targetEpoch)
if err != nil {
return ierrors.Wrapf(err, "failed to rollback pool rewards epochs to target epoch %d", targetEpoch)
}
}

for epochToPrune := targetEpoch + 1; epochToPrune <= max(
Expand Down

0 comments on commit e0a3fef

Please sign in to comment.