Merge PR #4485: rename expected pkg to exported

* rename expected pkg to exported

* rename pkg
This commit is contained in:
Federico Kunze
2019-06-05 13:42:25 -04:00
committed by frog power 4000
parent d322e23425
commit 9c65e47329
22 changed files with 76 additions and 76 deletions
+3 -3
View File
@@ -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())
+1 -1
View File
@@ -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)
}
}
}
+8 -8
View File
@@ -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)
}
}
+2 -2
View File
@@ -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())
+4 -4
View File
@@ -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)
+3 -3
View File
@@ -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
})
+3 -3
View File
@@ -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
},
+3 -3
View File
@@ -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())
+8 -8
View File
@@ -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
+3 -3
View File
@@ -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))
}
+3 -3
View File
@@ -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 {
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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",
+5 -5
View File
@@ -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
+2 -2
View File
@@ -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
},
@@ -1,4 +1,4 @@
package expected
package exported
import (
sdk "github.com/cosmos/cosmos-sdk/types"
+2 -2
View File
@@ -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(),
+8 -8
View File
@@ -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)
+2 -2
View File
@@ -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())
+2 -2
View File
@@ -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
+8 -8
View File
@@ -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))
}
//_______________________________________________________________________________
+3 -3
View File
@@ -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)
}