From 9c65e47329478c1ac16a46bd28fe14d7a3d87841 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Wed, 5 Jun 2019 19:42:25 +0200 Subject: [PATCH] Merge PR #4485: rename expected pkg to exported * rename expected pkg to exported * rename pkg --- simapp/export.go | 6 +++--- types/coin_test.go | 2 +- types/int_test.go | 16 ++++++++-------- x/distribution/keeper/allocation.go | 4 ++-- x/distribution/keeper/delegation.go | 8 ++++---- x/distribution/keeper/invariants.go | 6 +++--- x/distribution/keeper/querier.go | 6 +++--- x/distribution/keeper/validator.go | 6 +++--- x/distribution/types/expected_keepers.go | 16 ++++++++-------- x/gov/expected_keepers.go | 6 +++--- x/gov/tally.go | 6 +++--- x/simulation/doc.go | 2 +- x/simulation/operation.go | 2 +- x/slashing/expected_keepers.go | 10 +++++----- x/slashing/genesis.go | 4 ++-- .../expected.go => exported/exported.go} | 2 +- x/staking/genesis.go | 4 ++-- x/staking/keeper/alias_functions.go | 16 ++++++++-------- x/staking/keeper/invariants.go | 4 ++-- x/staking/types/delegation.go | 4 ++-- x/staking/types/expected_keepers.go | 16 ++++++++-------- x/staking/types/validator.go | 6 +++--- 22 files changed, 76 insertions(+), 76 deletions(-) rename x/staking/{expected/expected.go => exported/exported.go} (99%) diff --git a/simapp/export.go b/simapp/export.go index 8ce3358197..de2b2bac34 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // ExportAppStateAndValidators exports the state of the application for a genesis @@ -64,7 +64,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []str /* Handle fee distribution state. */ // withdraw all validator commission - app.stakingKeeper.IterateValidators(ctx, func(_ int64, val expected.ValidatorI) (stop bool) { + app.stakingKeeper.IterateValidators(ctx, func(_ int64, val exported.ValidatorI) (stop bool) { _, _ = app.distrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) return false }) @@ -86,7 +86,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []str ctx = ctx.WithBlockHeight(0) // reinitialize all validators - app.stakingKeeper.IterateValidators(ctx, func(_ int64, val expected.ValidatorI) (stop bool) { + app.stakingKeeper.IterateValidators(ctx, func(_ int64, val exported.ValidatorI) (stop bool) { // donate any unwithdrawn outstanding reward fraction tokens to the community pool scraps := app.distrKeeper.GetValidatorOutstandingRewards(ctx, val.GetOperator()) diff --git a/types/coin_test.go b/types/coin_test.go index c3a843e62d..9d6177afeb 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -201,7 +201,7 @@ func TestEqualCoins(t *testing.T) { require.Panics(t, func() { tc.inputOne.IsEqual(tc.inputTwo) }) } else { res := tc.inputOne.IsEqual(tc.inputTwo) - require.Equal(t, tc.expected, res, "Equality is differed from expected. tc #%d, expected %b, actual %b.", tcnum, tc.expected, res) + require.Equal(t, tc.expected, res, "Equality is differed from exported. tc #%d, expected %b, actual %b.", tcnum, tc.expected, res) } } } diff --git a/types/int_test.go b/types/int_test.go index 5251d46652..f6dbc1b407 100644 --- a/types/int_test.go +++ b/types/int_test.go @@ -332,17 +332,17 @@ func TestEncodingTableInt(t *testing.T) { for tcnum, tc := range cases { bz, err := tc.i.MarshalJSON() require.Nil(t, err, "Error marshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.bz, bz, "Marshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.bz, bz, "Marshaled value is different from exported. tc #%d", tcnum) err = (&i).UnmarshalJSON(bz) require.Nil(t, err, "Error unmarshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.i, i, "Unmarshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.i, i, "Unmarshaled value is different from exported. tc #%d", tcnum) str, err := tc.i.MarshalAmino() require.Nil(t, err, "Error marshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.str, str, "Marshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.str, str, "Marshaled value is different from exported. tc #%d", tcnum) err = (&i).UnmarshalAmino(str) require.Nil(t, err, "Error unmarshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.i, i, "Unmarshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.i, i, "Unmarshaled value is different from exported. tc #%d", tcnum) } } @@ -364,17 +364,17 @@ func TestEncodingTableUint(t *testing.T) { for tcnum, tc := range cases { bz, err := tc.i.MarshalJSON() require.Nil(t, err, "Error marshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.bz, bz, "Marshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.bz, bz, "Marshaled value is different from exported. tc #%d", tcnum) err = (&i).UnmarshalJSON(bz) require.Nil(t, err, "Error unmarshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.i, i, "Unmarshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.i, i, "Unmarshaled value is different from exported. tc #%d", tcnum) str, err := tc.i.MarshalAmino() require.Nil(t, err, "Error marshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.str, str, "Marshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.str, str, "Marshaled value is different from exported. tc #%d", tcnum) err = (&i).UnmarshalAmino(str) require.Nil(t, err, "Error unmarshaling Int. tc #%d, err %s", tcnum, err) - require.Equal(t, tc.i, i, "Unmarshaled value is different from expected. tc #%d", tcnum) + require.Equal(t, tc.i, i, "Unmarshaled value is different from exported. tc #%d", tcnum) } } diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index 11e7b61485..73ed04f60a 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -6,7 +6,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // allocate fees handles distribution of the collected fees @@ -84,7 +84,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context, sumPreviousPrecommitPower, total } // AllocateTokensToValidator allocate tokens to a particular validator, splitting according to commission -func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val expected.ValidatorI, tokens sdk.DecCoins) { +func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val exported.ValidatorI, tokens sdk.DecCoins) { // split tokens between validator and delegators according to commission commission := tokens.MulDec(val.GetCommission()) diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index 11e01e2c75..07a43a4889 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // initialize starting info for a new delegation @@ -28,7 +28,7 @@ func (k Keeper) initializeDelegation(ctx sdk.Context, val sdk.ValAddress, del sd } // calculate the rewards accrued by a delegation between two periods -func (k Keeper) calculateDelegationRewardsBetween(ctx sdk.Context, val expected.ValidatorI, +func (k Keeper) calculateDelegationRewardsBetween(ctx sdk.Context, val exported.ValidatorI, startingPeriod, endingPeriod uint64, stake sdk.Dec) (rewards sdk.DecCoins) { // sanity check if startingPeriod > endingPeriod { @@ -53,7 +53,7 @@ func (k Keeper) calculateDelegationRewardsBetween(ctx sdk.Context, val expected. } // calculate the total rewards accrued by a delegation -func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val expected.ValidatorI, del expected.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) { +func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val exported.ValidatorI, del exported.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins) { // fetch starting info for delegation startingInfo := k.GetDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) @@ -133,7 +133,7 @@ func (k Keeper) calculateDelegationRewards(ctx sdk.Context, val expected.Validat return rewards } -func (k Keeper) withdrawDelegationRewards(ctx sdk.Context, val expected.ValidatorI, del expected.DelegationI) (sdk.Coins, sdk.Error) { +func (k Keeper) withdrawDelegationRewards(ctx sdk.Context, val exported.ValidatorI, del exported.DelegationI) (sdk.Coins, sdk.Error) { // check existence of delegator starting info if !k.HasDelegatorStartingInfo(ctx, del.GetValidatorAddr(), del.GetDelegatorAddr()) { return nil, types.ErrNoDelegationDistInfo(k.codespace) diff --git a/x/distribution/keeper/invariants.go b/x/distribution/keeper/invariants.go index a08673d421..0814c876b8 100644 --- a/x/distribution/keeper/invariants.go +++ b/x/distribution/keeper/invariants.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // register all distribution invariants @@ -76,7 +76,7 @@ func CanWithdrawInvariant(k Keeper) sdk.Invariant { } // iterate over all validators - k.stakingKeeper.IterateValidators(ctx, func(_ int64, val expected.ValidatorI) (stop bool) { + k.stakingKeeper.IterateValidators(ctx, func(_ int64, val exported.ValidatorI) (stop bool) { _, _ = k.WithdrawValidatorCommission(ctx, val.GetOperator()) delegationAddrs, ok := valDelegationAddrs[val.GetOperator().String()] @@ -109,7 +109,7 @@ func ReferenceCountInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) error { valCount := uint64(0) - k.stakingKeeper.IterateValidators(ctx, func(_ int64, val expected.ValidatorI) (stop bool) { + k.stakingKeeper.IterateValidators(ctx, func(_ int64, val exported.ValidatorI) (stop bool) { valCount++ return false }) diff --git a/x/distribution/keeper/querier.go b/x/distribution/keeper/querier.go index 8bc5c703c6..2006206741 100644 --- a/x/distribution/keeper/querier.go +++ b/x/distribution/keeper/querier.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // nolint @@ -258,7 +258,7 @@ func queryDelegatorTotalRewards(ctx sdk.Context, _ []string, req abci.RequestQue k.stakingKeeper.IterateDelegations( ctx, params.DelegatorAddress, - func(_ int64, del expected.DelegationI) (stop bool) { + func(_ int64, del exported.DelegationI) (stop bool) { valAddr := del.GetValidatorAddr() val := k.stakingKeeper.Validator(ctx, valAddr) endingPeriod := k.incrementValidatorPeriod(ctx, val) @@ -293,7 +293,7 @@ func queryDelegatorValidators(ctx sdk.Context, _ []string, req abci.RequestQuery k.stakingKeeper.IterateDelegations( ctx, params.DelegatorAddress, - func(_ int64, del expected.DelegationI) (stop bool) { + func(_ int64, del exported.DelegationI) (stop bool) { validators = append(validators[:], del.GetValidatorAddr()) return false }, diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index 1aa14dc227..b0bbfca212 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -4,11 +4,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // initialize rewards for a new validator -func (k Keeper) initializeValidator(ctx sdk.Context, val expected.ValidatorI) { +func (k Keeper) initializeValidator(ctx sdk.Context, val exported.ValidatorI) { // set initial historical rewards (period 0) with reference count of 1 k.SetValidatorHistoricalRewards(ctx, val.GetOperator(), 0, types.NewValidatorHistoricalRewards(sdk.DecCoins{}, 1)) @@ -23,7 +23,7 @@ func (k Keeper) initializeValidator(ctx sdk.Context, val expected.ValidatorI) { } // increment validator period, returning the period just ended -func (k Keeper) incrementValidatorPeriod(ctx sdk.Context, val expected.ValidatorI) uint64 { +func (k Keeper) incrementValidatorPeriod(ctx sdk.Context, val exported.ValidatorI) uint64 { // fetch current rewards rewards := k.GetValidatorCurrentRewards(ctx, val.GetOperator()) diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index a4b6fdc47f..210592a2e6 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -3,25 +3,25 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // StakingKeeper expected staking keeper type StakingKeeper interface { // iterate through validators by operator address, execute func for each validator IterateValidators(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) // iterate through bonded validators by operator address, execute func for each validator IterateBondedValidatorsByPower(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) // iterate through the consensus validator set of the last block by operator address, execute func for each validator IterateLastValidators(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) - Validator(sdk.Context, sdk.ValAddress) expected.ValidatorI // get a particular validator by operator address - ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) expected.ValidatorI // get a particular validator by consensus address + Validator(sdk.Context, sdk.ValAddress) exported.ValidatorI // get a particular validator by operator address + ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) exported.ValidatorI // get a particular validator by consensus address TotalBondedTokens(sdk.Context) sdk.Int // total bonded tokens within the validator set TotalTokens(sdk.Context) sdk.Int // total token supply @@ -32,13 +32,13 @@ type StakingKeeper interface { // Delegation allows for getting a particular delegation for a given validator // and delegator outside the scope of the staking module. - Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) expected.DelegationI + Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) exported.DelegationI // MaxValidators returns the maximum amount of bonded validators MaxValidators(sdk.Context) uint16 IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, - fn func(index int64, delegation expected.DelegationI) (stop bool)) + fn func(index int64, delegation exported.DelegationI) (stop bool)) GetLastTotalPower(ctx sdk.Context) sdk.Int GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 diff --git a/x/gov/expected_keepers.go b/x/gov/expected_keepers.go index 25524997d6..15eb1e859d 100644 --- a/x/gov/expected_keepers.go +++ b/x/gov/expected_keepers.go @@ -2,7 +2,7 @@ package gov import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // expected bank keeper @@ -18,10 +18,10 @@ type BankKeeper interface { type StakingKeeper interface { // iterate through bonded validators by operator address, execute func for each validator IterateBondedValidatorsByPower(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) TotalBondedTokens(sdk.Context) sdk.Int // total bonded tokens within the validator set IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, - fn func(index int64, delegation expected.DelegationI) (stop bool)) + fn func(index int64, delegation exported.DelegationI) (stop bool)) } diff --git a/x/gov/tally.go b/x/gov/tally.go index 312db667b4..58160b8ab0 100644 --- a/x/gov/tally.go +++ b/x/gov/tally.go @@ -2,8 +2,8 @@ package gov import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // validatorGovInfo used for tallying @@ -39,7 +39,7 @@ func tally(ctx sdk.Context, keeper Keeper, proposal Proposal) (passes bool, burn currValidators := make(map[string]validatorGovInfo) // fetch all the bonded validators, insert them into currValidators - keeper.sk.IterateBondedValidatorsByPower(ctx, func(index int64, validator expected.ValidatorI) (stop bool) { + keeper.sk.IterateBondedValidatorsByPower(ctx, func(index int64, validator exported.ValidatorI) (stop bool) { currValidators[validator.GetOperator().String()] = newValidatorGovInfo( validator.GetOperator(), validator.GetBondedTokens(), @@ -60,7 +60,7 @@ func tally(ctx sdk.Context, keeper Keeper, proposal Proposal) (passes bool, burn currValidators[valAddrStr] = val } else { // iterate over all delegations from voter, deduct from any delegated-to validators - keeper.sk.IterateDelegations(ctx, vote.Voter, func(index int64, delegation expected.DelegationI) (stop bool) { + keeper.sk.IterateDelegations(ctx, vote.Voter, func(index int64, delegation exported.DelegationI) (stop bool) { valAddrStr := delegation.GetValidatorAddr().String() if val, ok := currValidators[valAddrStr]; ok { diff --git a/x/simulation/doc.go b/x/simulation/doc.go index ff292bd388..42fc97416e 100644 --- a/x/simulation/doc.go +++ b/x/simulation/doc.go @@ -14,7 +14,7 @@ misc. parameters that affect simulation speed. It is intended that every module provides a list of Operations which will randomly create and run a message / tx in a manner that is interesting to fuzz, -and verify that the state transition was executed as expected. Each module +and verify that the state transition was executed as exported. Each module should additionally provide methods to assert that the desired invariants hold. Then to perform a randomized simulation, select the set of desired operations, diff --git a/x/simulation/operation.go b/x/simulation/operation.go index 31bedc7584..3b1c26d2b5 100644 --- a/x/simulation/operation.go +++ b/x/simulation/operation.go @@ -12,7 +12,7 @@ import ( ) // Operation runs a state machine transition, and ensures the transition -// happened as expected. The operation could be running and testing a fuzzed +// happened as exported. The operation could be running and testing a fuzzed // transaction, or doing the same for a message. // // For ease of debugging, an operation returns a descriptive message "action", diff --git a/x/slashing/expected_keepers.go b/x/slashing/expected_keepers.go index 988129b6db..0c2f20a6fb 100644 --- a/x/slashing/expected_keepers.go +++ b/x/slashing/expected_keepers.go @@ -3,7 +3,7 @@ package slashing import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // AccountKeeper expected account keeper @@ -15,10 +15,10 @@ type AccountKeeper interface { type StakingKeeper interface { // iterate through validators by operator address, execute func for each validator IterateValidators(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) - Validator(sdk.Context, sdk.ValAddress) expected.ValidatorI // get a particular validator by operator address - ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) expected.ValidatorI // get a particular validator by consensus address + Validator(sdk.Context, sdk.ValAddress) exported.ValidatorI // get a particular validator by operator address + ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) exported.ValidatorI // get a particular validator by consensus address // slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) @@ -27,7 +27,7 @@ type StakingKeeper interface { // Delegation allows for getting a particular delegation for a given validator // and delegator outside the scope of the staking module. - Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) expected.DelegationI + Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) exported.DelegationI // MaxValidators returns the maximum amount of bonded validators MaxValidators(sdk.Context) uint16 diff --git a/x/slashing/genesis.go b/x/slashing/genesis.go index 3cf27670fc..ab9f0a0ef8 100644 --- a/x/slashing/genesis.go +++ b/x/slashing/genesis.go @@ -5,7 +5,7 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // GenesisState - all slashing state that must be provided at genesis @@ -80,7 +80,7 @@ func ValidateGenesis(data GenesisState) error { // and the keeper's address to pubkey map func InitGenesis(ctx sdk.Context, keeper Keeper, stakingKeeper StakingKeeper, data GenesisState) { stakingKeeper.IterateValidators(ctx, - func(index int64, validator expected.ValidatorI) bool { + func(index int64, validator exported.ValidatorI) bool { keeper.addPubkey(ctx, validator.GetConsPubKey()) return false }, diff --git a/x/staking/expected/expected.go b/x/staking/exported/exported.go similarity index 99% rename from x/staking/expected/expected.go rename to x/staking/exported/exported.go index 1f01405a5d..496fda5a56 100644 --- a/x/staking/expected/expected.go +++ b/x/staking/exported/exported.go @@ -1,4 +1,4 @@ -package expected +package exported import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/genesis.go b/x/staking/genesis.go index c7cb6fbdfc..86985ff134 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -144,7 +144,7 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState { // WriteValidators returns a slice of bonded genesis validators. func WriteValidators(ctx sdk.Context, keeper Keeper) (vals []tmtypes.GenesisValidator) { - keeper.IterateLastValidators(ctx, func(_ int64, validator expected.ValidatorI) (stop bool) { + keeper.IterateLastValidators(ctx, func(_ int64, validator exported.ValidatorI) (stop bool) { vals = append(vals, tmtypes.GenesisValidator{ PubKey: validator.GetConsPubKey(), Power: validator.GetTendermintPower(), diff --git a/x/staking/keeper/alias_functions.go b/x/staking/keeper/alias_functions.go index 396e25c2bd..be9cf20783 100644 --- a/x/staking/keeper/alias_functions.go +++ b/x/staking/keeper/alias_functions.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -12,7 +12,7 @@ import ( // Validator Set // iterate through the validator set and perform the provided function -func (k Keeper) IterateValidators(ctx sdk.Context, fn func(index int64, validator expected.ValidatorI) (stop bool)) { +func (k Keeper) IterateValidators(ctx sdk.Context, fn func(index int64, validator exported.ValidatorI) (stop bool)) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.ValidatorsKey) defer iterator.Close() @@ -28,7 +28,7 @@ func (k Keeper) IterateValidators(ctx sdk.Context, fn func(index int64, validato } // iterate through the bonded validator set and perform the provided function -func (k Keeper) IterateBondedValidatorsByPower(ctx sdk.Context, fn func(index int64, validator expected.ValidatorI) (stop bool)) { +func (k Keeper) IterateBondedValidatorsByPower(ctx sdk.Context, fn func(index int64, validator exported.ValidatorI) (stop bool)) { store := ctx.KVStore(k.storeKey) maxValidators := k.MaxValidators(ctx) @@ -51,7 +51,7 @@ func (k Keeper) IterateBondedValidatorsByPower(ctx sdk.Context, fn func(index in } // iterate through the active validator set and perform the provided function -func (k Keeper) IterateLastValidators(ctx sdk.Context, fn func(index int64, validator expected.ValidatorI) (stop bool)) { +func (k Keeper) IterateLastValidators(ctx sdk.Context, fn func(index int64, validator exported.ValidatorI) (stop bool)) { iterator := k.LastValidatorsIterator(ctx) defer iterator.Close() i := int64(0) @@ -71,7 +71,7 @@ func (k Keeper) IterateLastValidators(ctx sdk.Context, fn func(index int64, vali } // Validator gets the Validator interface for a particular address -func (k Keeper) Validator(ctx sdk.Context, address sdk.ValAddress) expected.ValidatorI { +func (k Keeper) Validator(ctx sdk.Context, address sdk.ValAddress) exported.ValidatorI { val, found := k.GetValidator(ctx, address) if !found { return nil @@ -80,7 +80,7 @@ func (k Keeper) Validator(ctx sdk.Context, address sdk.ValAddress) expected.Vali } // ValidatorByConsAddr gets the validator interface for a particular pubkey -func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) expected.ValidatorI { +func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) exported.ValidatorI { val, found := k.GetValidatorByConsAddr(ctx, addr) if !found { return nil @@ -122,7 +122,7 @@ func (k Keeper) GetValidatorSet() types.ValidatorSet { } // Delegation get the delegation interface for a particular set of delegator and validator addresses -func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk.ValAddress) expected.DelegationI { +func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk.ValAddress) exported.DelegationI { bond, ok := k.GetDelegation(ctx, addrDel, addrVal) if !ok { return nil @@ -133,7 +133,7 @@ func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk. // iterate through all of the delegations from a delegator func (k Keeper) IterateDelegations(ctx sdk.Context, delAddr sdk.AccAddress, - fn func(index int64, del expected.DelegationI) (stop bool)) { + fn func(index int64, del exported.DelegationI) (stop bool)) { store := ctx.KVStore(k.storeKey) delegatorPrefixKey := types.GetDelegationsKey(delAddr) diff --git a/x/staking/keeper/invariants.go b/x/staking/keeper/invariants.go index cab337000f..a572d9197b 100644 --- a/x/staking/keeper/invariants.go +++ b/x/staking/keeper/invariants.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -73,7 +73,7 @@ func SupplyInvariants(k Keeper, f types.FeeCollectionKeeper, } return false }) - k.IterateValidators(ctx, func(_ int64, validator expected.ValidatorI) bool { + k.IterateValidators(ctx, func(_ int64, validator exported.ValidatorI) bool { switch validator.GetStatus() { case sdk.Bonded: bonded = bonded.Add(validator.GetBondedTokens().ToDec()) diff --git a/x/staking/types/delegation.go b/x/staking/types/delegation.go index 78a75a0f5c..04c4344d92 100644 --- a/x/staking/types/delegation.go +++ b/x/staking/types/delegation.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // DVPair is struct that just has a delegator-validator pair with no other data. @@ -30,7 +30,7 @@ type DVVTriplet struct { } // Implements Delegation interface -var _ expected.DelegationI = Delegation{} +var _ exported.DelegationI = Delegation{} // Delegation represents the bond with tokens held by an account. It is // owned by one delegator, and is associated with the voting power of one diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index e319589a2d..c029320721 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -3,7 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // expected coin keeper @@ -32,18 +32,18 @@ type AccountKeeper interface { type ValidatorSet interface { // iterate through validators by operator address, execute func for each validator IterateValidators(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) // iterate through bonded validators by operator address, execute func for each validator IterateBondedValidatorsByPower(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) // iterate through the consensus validator set of the last block by operator address, execute func for each validator IterateLastValidators(sdk.Context, - func(index int64, validator expected.ValidatorI) (stop bool)) + func(index int64, validator exported.ValidatorI) (stop bool)) - Validator(sdk.Context, sdk.ValAddress) expected.ValidatorI // get a particular validator by operator address - ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) expected.ValidatorI // get a particular validator by consensus address + Validator(sdk.Context, sdk.ValAddress) exported.ValidatorI // get a particular validator by operator address + ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) exported.ValidatorI // get a particular validator by consensus address TotalBondedTokens(sdk.Context) sdk.Int // total bonded tokens within the validator set TotalTokens(sdk.Context) sdk.Int // total token supply @@ -54,7 +54,7 @@ type ValidatorSet interface { // Delegation allows for getting a particular delegation for a given validator // and delegator outside the scope of the staking module. - Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) expected.DelegationI + Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) exported.DelegationI // MaxValidators returns the maximum amount of bonded validators MaxValidators(sdk.Context) uint16 @@ -67,7 +67,7 @@ type DelegationSet interface { // iterate through all delegations from one delegator by validator-AccAddress, // execute func for each validator IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, - fn func(index int64, delegation expected.DelegationI) (stop bool)) + fn func(index int64, delegation exported.DelegationI) (stop bool)) } //_______________________________________________________________________________ diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 1c380161d8..d97a2039d4 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/expected" + "github.com/cosmos/cosmos-sdk/x/staking/exported" ) // nolint @@ -25,7 +25,7 @@ const ( ) // Implements Validator interface -var _ expected.ValidatorI = Validator{} +var _ exported.ValidatorI = Validator{} // Validator defines the total amount of bond shares and their exchange rate to // coins. Slashing results in a decrease in the exchange rate, allowing correct @@ -59,7 +59,7 @@ func (v Validators) String() (out string) { } // ToSDKValidators - convenience function convert []Validators to []sdk.Validators -func (v Validators) ToSDKValidators() (validators []expected.ValidatorI) { +func (v Validators) ToSDKValidators() (validators []exported.ValidatorI) { for _, val := range v { validators = append(validators, val) }