forked from cosmos/cosmos-sdk
/
migrate.go
30 lines (27 loc) · 1.2 KB
/
migrate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package v036
import (
v034distr "github.com/JaTochNietDan/cosmos-sdk/x/distribution/legacy/v034"
)
// Migrate accepts exported genesis state from v0.34 and migrates it to v0.36
// genesis state. All entries are identical except for validator slashing events
// which now include the period.
func Migrate(oldGenState v034distr.GenesisState) GenesisState {
// migrate slash events which now have the period included
slashEvents := make([]ValidatorSlashEventRecord, len(oldGenState.ValidatorSlashEvents))
for i, se := range oldGenState.ValidatorSlashEvents {
slashEvents[i] = ValidatorSlashEventRecord{
ValidatorAddress: se.ValidatorAddress,
Height: se.Height,
Period: se.Event.ValidatorPeriod,
Event: se.Event,
}
}
return NewGenesisState(
oldGenState.FeePool, oldGenState.CommunityTax, oldGenState.BaseProposerReward,
oldGenState.BonusProposerReward, oldGenState.WithdrawAddrEnabled,
oldGenState.DelegatorWithdrawInfos, oldGenState.PreviousProposer,
oldGenState.OutstandingRewards, oldGenState.ValidatorAccumulatedCommissions,
oldGenState.ValidatorHistoricalRewards, oldGenState.ValidatorCurrentRewards,
oldGenState.DelegatorStartingInfos, slashEvents,
)
}