refactor(x/staking,genutil)!: use validatorUpdates (#19754)
Co-authored-by: chixiaoxiao <chixiaoxiao@gmail.com>
This commit is contained in:
co-authored by
chixiaoxiao
parent
a1bfe5d285
commit
bfa734ce8f
+1
-25
@@ -78,31 +78,7 @@ func (am AppModule) ValidateGenesis(bz json.RawMessage) error {
|
||||
func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) ([]module.ValidatorUpdate, error) {
|
||||
var genesisState types.GenesisState
|
||||
am.cdc.MustUnmarshalJSON(data, &genesisState)
|
||||
cometValidatorUpdates, err := InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
validatorUpdates := make([]module.ValidatorUpdate, len(cometValidatorUpdates))
|
||||
for i, v := range cometValidatorUpdates {
|
||||
if ed25519 := v.PubKey.GetEd25519(); len(ed25519) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: ed25519,
|
||||
PubKeyType: "ed25519",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else if secp256k1 := v.PubKey.GetSecp256K1(); len(secp256k1) > 0 {
|
||||
validatorUpdates[i] = module.ValidatorUpdate{
|
||||
PubKey: secp256k1,
|
||||
PubKeyType: "secp256k1",
|
||||
Power: v.Power,
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("unexpected validator pubkey type: %T", v.PubKey)
|
||||
}
|
||||
}
|
||||
|
||||
return validatorUpdates, nil
|
||||
return InitGenesis(ctx, am.stakingKeeper, am.deliverTx, genesisState, am.txEncodingConfig)
|
||||
}
|
||||
|
||||
// ExportGenesis returns the exported genesis state as raw bytes for the genutil module.
|
||||
|
||||
Reference in New Issue
Block a user