func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate {
	return abci.ValidatorUpdate{
		PubKey: tmtypes.TM2PB.PubKey(v.GetConsPubKey()),
		Power:  0,
	}
}
ABCIValidatorUpdateZero returns an abci.ValidatorUpdate from a staking validator type
with zero power used for validator updates.
package types
import (
	"bytes"
	"fmt"
	"sort"
	"strings"
	"time"
	"github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/KuChainNetwork/kuchain/x/staking/exported"
	stakingexport "github.com/KuChainNetwork/kuchain/x/staking/exported"
	"github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
	abci "github.com/tendermint/tendermint/abci/types"
	"github.com/tendermint/tendermint/crypto"
	tmtypes "github.com/tendermint/tendermint/types"
	yaml "gopkg.in/yaml.v2"
)
const (
	MaxMonikerLength         = 70
	MaxIdentityLength        = 3000
	MaxWebsiteLength         = 140
	MaxSecurityContactLength = 140
	MaxDetailsLength         = 280
)
var _ exported.ValidatorI = Validator{}
type Validator struct {
	OperatorAccount   AccountID                `json:"operator_account" yaml:"operator_account"`
	ConsensusPubkey   string                   `json:"consensus_pubkey,omitempty" yaml:"consensus_pubkey"`
	Jailed            bool                     `json:"jailed,omitempty" yaml:"jailed"`
	Status            stakingexport.BondStatus `json:"status,omitempty" yaml:"status"`
	Tokens            sdk.Int                  `json:"tokens" yaml:"tokens"`
	DelegatorShares   Dec                      `json:"delegator_shares" yaml:"delegator_shares"`
	Description       Description              `json:"description" yaml:"description"`
	UnbondingHeight   int64                    `json:"unbonding_height,omitempty" yaml:"unbonding_height"`
	UnbondingTime     time.Time                `json:"unbonding_time" yaml:"unbonding_time"`
	Commission        Commission               `json:"commission" yaml:"commission"`
	MinSelfDelegation sdk.Int                  `json:"min_self_delegation" yaml:"min_self_delegation"`
}
func NewValidator(operator types.AccountID, pubKey crypto.PubKey, description Description) Validator {
	var pkStr string
	if pubKey != nil {
		pkStr = sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pubKey)
	}
	return Validator{
		OperatorAccount:   operator,
		ConsensusPubkey:   pkStr,
		Jailed:            false,
		Status:            stakingexport.Unbonded,
		Tokens:            sdk.ZeroInt(),
		DelegatorShares:   sdk.ZeroDec(),
		Description:       description,
		UnbondingHeight:   int64(0),
		UnbondingTime:     time.Unix(0, 0).UTC(),
		Commission:        NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
		MinSelfDelegation: sdk.OneInt(),
	}
}
func (v Validator) String() string {
	out, _ := yaml.Marshal(v)
	return string(out)
}
type Validators []Validator
func (v Validators) String() (out string) {
	for _, val := range v {
		out += val.String() + "\n"
	}
	return strings.TrimSpace(out)
}
func (v Validators) ToSDKValidators() (validators []exported.ValidatorI) {
	for _, val := range v {
		validators = append(validators, val)
	}
	return validators
}
func (v Validators) ToTmValidators() []*tmtypes.Validator {
	validators := make([]*tmtypes.Validator, len(v))
	for i, val := range v {
		validators[i] = val.ToTmValidator()
	}
	return validators
}
func (v Validators) Sort() {
	sort.Sort(v)
}
func (v Validators) Len() int {
	return len(v)
}
func (v Validators) Less(i, j int) bool {
	return bytes.Compare(v[i].OperatorAccount.Value, v[j].OperatorAccount.Value) == -1
}
func (v Validators) Swap(i, j int) {
	it := v[i]
	v[i] = v[j]
	v[j] = it
}
func MustMarshalValidator(cdc *codec.Codec, validator Validator) []byte {
	return cdc.MustMarshalBinaryBare(&validator)
}
func MustUnmarshalValidator(cdc *codec.Codec, value []byte) Validator {
	validator, err := UnmarshalValidator(cdc, value)
	if err != nil {
		panic(err)
	}
	return validator
}
func UnmarshalValidator(cdc *codec.Codec, value []byte) (v Validator, err error) {
	err = cdc.UnmarshalBinaryBare(value, &v)
	return v, err
}
func (v Validator) IsBonded() bool {
	return v.GetStatus().Equal(stakingexport.Bonded)
}
func (v Validator) IsUnbonded() bool {
	return v.GetStatus().Equal(stakingexport.Unbonded)
}
func (v Validator) IsUnbonding() bool {
	return v.GetStatus().Equal(stakingexport.Unbonding)
}
const DoNotModifyDesc = "[do-not-modify]"
type Description struct {
	Moniker         string `json:"moniker,omitempty" yaml:"moniker"`
	Identity        string `json:"identity,omitempty" yaml:"identity"`
	Website         string `json:"website,omitempty" yaml:"website"`
	SecurityContact string `json:"security_contact,omitempty" yaml:"security_contact"`
	Details         string `json:"details,omitempty" yaml:"details"`
}
func NewDescription(moniker, identity, website, securityContact, details string) Description {
	return Description{
		Moniker:         moniker,
		Identity:        identity,
		Website:         website,
		SecurityContact: securityContact,
		Details:         details,
	}
}
func (d Description) String() string {
	out, _ := yaml.Marshal(d)
	return string(out)
}
func (d Description) UpdateDescription(d2 Description) (Description, error) {
	if d2.Moniker == DoNotModifyDesc {
		d2.Moniker = d.Moniker
	}
	if d2.Identity == DoNotModifyDesc {
		d2.Identity = d.Identity
	}
	if d2.Website == DoNotModifyDesc {
		d2.Website = d.Website
	}
	if d2.SecurityContact == DoNotModifyDesc {
		d2.SecurityContact = d.SecurityContact
	}
	if d2.Details == DoNotModifyDesc {
		d2.Details = d.Details
	}
	return NewDescription(
		d2.Moniker,
		d2.Identity,
		d2.Website,
		d2.SecurityContact,
		d2.Details,
	).EnsureLength()
}
func (d Description) EnsureLength() (Description, error) {
	if len(d.Moniker) > MaxMonikerLength {
		return d, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid moniker length; got: %d, max: %d", len(d.Moniker), MaxMonikerLength)
	}
	if len(d.Identity) > MaxIdentityLength {
		return d, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid identity length; got: %d, max: %d", len(d.Identity), MaxIdentityLength)
	}
	if len(d.Website) > MaxWebsiteLength {
		return d, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid website length; got: %d, max: %d", len(d.Website), MaxWebsiteLength)
	}
	if len(d.SecurityContact) > MaxSecurityContactLength {
		return d, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid security contact length; got: %d, max: %d", len(d.SecurityContact), MaxSecurityContactLength)
	}
	if len(d.Details) > MaxDetailsLength {
		return d, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid details length; got: %d, max: %d", len(d.Details), MaxDetailsLength)
	}
	return d, nil
}
func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate {
	return abci.ValidatorUpdate{
		PubKey: tmtypes.TM2PB.PubKey(v.GetConsPubKey()),
		Power:  v.ConsensusPower(),
	}
}