Skip to content

Commit

Permalink
Fixed genesis snapshot generation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsporn committed May 14, 2024
1 parent 98642f3 commit dc72db4
Showing 1 changed file with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,46 +300,46 @@ func (t *Tracker) exportPoolRewards(writer io.WriteSeeker, targetEpoch iotago.Ep
if err != nil {
return 0, ierrors.Wrapf(err, "unable to get rewards tree for epoch %d", epoch)
}
// if the map was not present in storage we can skip this epoch
if !rewardsMap.WasRestoredFromStorage() {
t.LogDebug("Skipping epoch", "epoch", epoch, "reason", "not restored from storage")
continue
}

t.LogDebug("Exporting Pool Rewards", "epoch", epoch)
if rewardsMap.WasRestoredFromStorage() {
t.LogDebug("Exporting Pool Rewards", "epoch", epoch)

if err := stream.Write(writer, epoch); err != nil {
return 0, ierrors.Wrapf(err, "unable to write epoch index for epoch index %d", epoch)
}
if err := stream.Write(writer, epoch); err != nil {
return 0, ierrors.Wrapf(err, "unable to write epoch index for epoch index %d", epoch)
}

if err := stream.WriteCollection(writer, serializer.SeriLengthPrefixTypeAsUint64, func() (int, error) {
var accountCount int
if err := stream.WriteCollection(writer, serializer.SeriLengthPrefixTypeAsUint64, func() (int, error) {
var accountCount int

if err = rewardsMap.Stream(func(key iotago.AccountID, value *model.PoolRewards) error {
if err := stream.Write(writer, key); err != nil {
return ierrors.Wrapf(err, "unable to write account id for epoch %d and accountID %s", epoch, key)
}
if err = rewardsMap.Stream(func(key iotago.AccountID, value *model.PoolRewards) error {
if err := stream.Write(writer, key); err != nil {
return ierrors.Wrapf(err, "unable to write account id for epoch %d and accountID %s", epoch, key)
}

if err := stream.WriteObject(writer, value, (*model.PoolRewards).Bytes); err != nil {
return ierrors.Wrapf(err, "unable to write account rewards for epoch index %d and accountID %s", epoch, key)
}
if err := stream.WriteObject(writer, value, (*model.PoolRewards).Bytes); err != nil {
return ierrors.Wrapf(err, "unable to write account rewards for epoch index %d and accountID %s", epoch, key)
}

t.LogDebug("Exporting Pool Reward", "epoch", epoch, "accountID", key, "rewards", value)
t.LogDebug("Exporting Pool Reward", "epoch", epoch, "accountID", key, "rewards", value)

accountCount++
accountCount++

return nil
return nil
}); err != nil {
return 0, ierrors.Wrapf(err, "unable to stream rewards for epoch index %d", epoch)
}

return accountCount, nil
}); err != nil {
return 0, ierrors.Wrapf(err, "unable to stream rewards for epoch index %d", epoch)
return 0, ierrors.Wrapf(err, "unable to write rewards for epoch index %d", epoch)
}

return accountCount, nil
}); err != nil {
return 0, ierrors.Wrapf(err, "unable to write rewards for epoch index %d", epoch)
epochCount++
} else {
// if the map was not present in storage we can skip this epoch
t.LogDebug("Skipping epoch", "epoch", epoch, "reason", "not restored from storage")
}

epochCount++

if epoch <= earliestRewardEpoch {
// Every reward before earliestRewardEpoch is already exported, so stop here
break
Expand Down

0 comments on commit dc72db4

Please sign in to comment.