Skip to content

Commit

Permalink
Merge branch 'fix_potential_mana_rounding' of https://github.com/iota…
Browse files Browse the repository at this point in the history
…ledger/iota.go into fix_potential_mana_rounding
  • Loading branch information
oliviasaa committed Oct 20, 2023
2 parents 9099cf9 + d709712 commit e93e389
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mana_decay_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,17 @@ func (p *ManaDecayProvider) ManaGenerationWithDecay(amount BaseToken, creationSl

//nolint:exhaustive // false-positive, we have a default case
switch epochDiff {
// case 0 means that the creationSlot and targetSlot belong to the same epoch. In that case, we generate mana according to the slotDiff, and no decay is applied
case 0:
result, err := p.generateMana(amount, targetSlot-creationSlot)
if err != nil {
return 0, ierrors.Wrap(err, "failed to calculate generated mana")
}

return result, nil


Check failure on line 198 in mana_decay_provider.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] mana_decay_provider.go#L198

File is not `gofmt`-ed with `-s` (gofmt)
Raw output
mana_decay_provider.go:198: File is not `gofmt`-ed with `-s` (gofmt)
		
	// case 0 means that the creationSlot and targetSlot belong to subsequent epochs. 
// case 0 means that the creationSlot and targetSlot belong to subsequent epochs.
// In that case, we generate the mana for the slots belonging to the first epoch and decay it, later we add it to the undecayed mana of the second epoch
case 1:
manaGeneratedFirstEpoch, err := p.generateMana(amount, p.timeProvider.SlotsBeforeNextEpoch(creationSlot))
if err != nil {
Expand All @@ -218,6 +221,8 @@ func (p *ManaDecayProvider) ManaGenerationWithDecay(amount BaseToken, creationSl

return result, nil

// the default case means that the creationSlot and targetSlot belong to separated epochs.
// Parts of the generated mana are decayed by epochDiff epochs, other parts by epochDiff-1, and other parts are not decayed at all
default:
aux, err := fixedPointMultiplication32(uint64(amount), p.decayFactorEpochsSum*p.generationRate, p.decayFactorEpochsSumExponent+p.generationRateExponent-p.slotsPerEpochExponent)
if err != nil {
Expand Down

0 comments on commit e93e389

Please sign in to comment.