Merge PR #3507: Results from x/staking & x/slashing peer review
This commit is contained in:
committed by
Jack Zampolin
parent
a5c1c7e998
commit
38068a59ea
+5
-11
@@ -1,7 +1,6 @@
|
||||
package staking
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"time"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
@@ -87,20 +86,16 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, sdk.T
|
||||
return validatorUpdates, resTags
|
||||
}
|
||||
|
||||
//_____________________________________________________________________
|
||||
|
||||
// These functions assume everything has been authenticated,
|
||||
// now we just perform action and save
|
||||
|
||||
func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k keeper.Keeper) sdk.Result {
|
||||
// check to see if the pubkey or sender has been registered before
|
||||
_, found := k.GetValidator(ctx, msg.ValidatorAddr)
|
||||
if found {
|
||||
if _, found := k.GetValidator(ctx, msg.ValidatorAddr); found {
|
||||
return ErrValidatorOwnerExists(k.Codespace()).Result()
|
||||
}
|
||||
|
||||
_, found = k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(msg.PubKey))
|
||||
if found {
|
||||
if _, found := k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(msg.PubKey)); found {
|
||||
return ErrValidatorPubKeyExists(k.Codespace()).Result()
|
||||
}
|
||||
|
||||
@@ -135,6 +130,7 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
|
||||
k.SetValidatorByConsAddr(ctx, validator)
|
||||
k.SetNewValidatorByPowerIndex(ctx, validator)
|
||||
|
||||
// call the after-creation hook
|
||||
k.AfterValidatorCreated(ctx, validator.OperatorAddr)
|
||||
|
||||
// move coins from the msg.Address account to a (self-delegation) delegator account
|
||||
@@ -176,7 +172,9 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
|
||||
return err.Result()
|
||||
}
|
||||
|
||||
// call the before-modification hook since we're about to update the commission
|
||||
k.BeforeValidatorModified(ctx, msg.ValidatorAddr)
|
||||
|
||||
validator.Commission = commission
|
||||
}
|
||||
|
||||
@@ -203,10 +201,6 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper)
|
||||
return ErrBadDenom(k.Codespace()).Result()
|
||||
}
|
||||
|
||||
if validator.Jailed && !bytes.Equal(validator.OperatorAddr, msg.DelegatorAddr) {
|
||||
return ErrValidatorJailed(k.Codespace()).Result()
|
||||
}
|
||||
|
||||
_, err := k.Delegate(ctx, msg.DelegatorAddr, msg.Value, validator, true)
|
||||
if err != nil {
|
||||
return err.Result()
|
||||
|
||||
Reference in New Issue
Block a user