func (k Keeper) DeleteValidatorHistoricalRewards(ctx sdk.Context, val AccountID) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.GetValidatorHistoricalRewardsPrefix(val))
	defer iter.Close()
	for ; iter.Valid(); iter.Next() {
		store.Delete(iter.Key())
	}
}
delete historical rewards for a validator
package keeper
import (
	chainType "github.com/KuChainNetwork/kuchain/chain/types"
	gogotypes "github.com/gogo/protobuf/types"
	"github.com/KuChainNetwork/kuchain/x/distribution/types"
	sdk "github.com/cosmos/cosmos-sdk/types"
)
func (k Keeper) GetDelegatorWithdrawAddr(ctx sdk.Context, delAddr AccountID) AccountID {
	store := ctx.KVStore(k.storeKey)
	b := store.Get(types.GetDelegatorWithdrawAddrKey(delAddr))
	if b == nil {
		return delAddr
	}
	return chainType.NewAccountIDFromByte(b)
}
func (k Keeper) SetDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr AccountID) {
	store := ctx.KVStore(k.storeKey)
	store.Set(types.GetDelegatorWithdrawAddrKey(delAddr), withdrawAddr.Value)
}
func (k Keeper) DeleteDelegatorWithdrawAddr(ctx sdk.Context, delId, withdrawId AccountID) {
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetDelegatorWithdrawAddrKey(delId))
}
func (k Keeper) IterateDelegatorWithdrawAddId(ctx sdk.Context, handler func(del AccountID, addr AccountID) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.DelegatorWithdrawAddrPrefix)
	defer iter.Close()
	for ; iter.Valid(); iter.Next() {
		addId, _ := chainType.NewAccountIDFromStr(string(iter.Value()))
		del := types.GetDelegatorWithdrawInfoAddressUseAccountId(iter.Key())
		if handler(del, addId) {
			break
		}
	}
}
func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool) {
	store := ctx.KVStore(k.storeKey)
	b := store.Get(types.FeePoolKey)
	if b == nil {
		panic("Stored fee pool should not have been nil")
	}
	k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &feePool)
	return
}
func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool) {
	store := ctx.KVStore(k.storeKey)
	b := k.cdc.MustMarshalBinaryLengthPrefixed(&feePool)
	store.Set(types.FeePoolKey, b)
}
func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) sdk.ConsAddress {
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.ProposerKey)
	if bz == nil {
		panic("previous proposer not set")
	}
	addrValue := gogotypes.BytesValue{}
	k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &addrValue)
	return sdk.ConsAddress(addrValue.Value)
}
func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) {
	store := ctx.KVStore(k.storeKey)
	bz := k.cdc.MustMarshalBinaryLengthPrefixed(&gogotypes.BytesValue{Value: consAddr.Bytes()})
	store.Set(types.ProposerKey, bz)
}
func (k Keeper) GetDelegatorStartingInfo(ctx sdk.Context, val AccountID, del AccountID) (period types.DelegatorStartingInfo) {
	store := ctx.KVStore(k.storeKey)
	b := store.Get(types.GetDelegatorStartingInfoKey(val, del))
	k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &period)
	return
}
func (k Keeper) SetDelegatorStartingInfo(ctx sdk.Context, val AccountID, del AccountID, period types.DelegatorStartingInfo) {
	store := ctx.KVStore(k.storeKey)
	b := k.cdc.MustMarshalBinaryLengthPrefixed(&period)
	store.Set(types.GetDelegatorStartingInfoKey(val, del), b)
}
func (k Keeper) HasDelegatorStartingInfo(ctx sdk.Context, val AccountID, del AccountID) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetDelegatorStartingInfoKey(val, del))
}
func (k Keeper) DeleteDelegatorStartingInfo(ctx sdk.Context, val AccountID, del AccountID) {
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetDelegatorStartingInfoKey(val, del))
}
func (k Keeper) IterateDelegatorStartingInfos(ctx sdk.Context, handler func(val AccountID, del AccountID, info types.DelegatorStartingInfo) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.DelegatorStartingInfoPrefix)
	defer iter.Close()
	for ; iter.Valid(); iter.Next() {
		var info types.DelegatorStartingInfo
		k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), &info)
		val, del := types.GetDelegatorStartingInfoAddresses(iter.Key())
		if handler(val, del, info) {
			break
		}
	}
}
func (k Keeper) GetValidatorHistoricalRewards(ctx sdk.Context, val AccountID, period uint64) (rewards types.ValidatorHistoricalRewards) {
	store := ctx.KVStore(k.storeKey)
	b := store.Get(types.GetValidatorHistoricalRewardsKey(val, period))
	k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &rewards)
	return
}
func (k Keeper) SetValidatorHistoricalRewards(ctx sdk.Context, val AccountID, period uint64, rewards types.ValidatorHistoricalRewards) {
	store := ctx.KVStore(k.storeKey)
	b := k.cdc.MustMarshalBinaryLengthPrefixed(&rewards)
	store.Set(types.GetValidatorHistoricalRewardsKey(val, period), b)
}
func (k Keeper) IterateValidatorHistoricalRewards(ctx sdk.Context, handler func(val AccountID, period uint64, rewards types.ValidatorHistoricalRewards) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.ValidatorHistoricalRewardsPrefix)
	defer iter.Close()
	for ; iter.Valid(); iter.Next() {
		var rewards types.ValidatorHistoricalRewards
		k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), &rewards)
		addr, period := types.GetValidatorHistoricalRewardsAddressPeriod(iter.Key())
		if handler(addr, period, rewards) {
			break
		}
	}
}
func (k Keeper) DeleteValidatorHistoricalReward(ctx sdk.Context, val AccountID, period uint64) {
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetValidatorHistoricalRewardsKey(val, period))
}