keeper

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 23 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

func SetDelegationKeeper

func SetDelegationKeeper(k *Keeper, delegationKeeper delegationKeeper.Keeper)

Types

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey storetypes.StoreKey,
	memKey storetypes.StoreKey,

	authority string,

	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	distrkeeper types.DistrKeeper,
	poolKeeper types.PoolKeeper,
	upgradeKeeper types.UpgradeKeeper,
) *Keeper

func (Keeper) AddActiveStaker

func (k Keeper) AddActiveStaker(ctx sdk.Context, staker string)

AddActiveStaker increases the active-staker-count of the given staker by one. The amount tracks the number of pools the staker is in. It also allows to determine that a given staker is at least in one pool.

func (Keeper) AddOneToCount

func (k Keeper) AddOneToCount(ctx sdk.Context, poolId uint64)

func (Keeper) AddValaccountToPool

func (k Keeper) AddValaccountToPool(ctx sdk.Context, poolId uint64, stakerAddress string, valaddress string)

AddValaccountToPool adds a valaccount to a pool. If valaccount already belongs to pool, nothing happens.

func (Keeper) AppendStaker

func (k Keeper) AppendStaker(ctx sdk.Context, staker types.Staker)

func (Keeper) AssertValaccountAuthorized

func (k Keeper) AssertValaccountAuthorized(ctx sdk.Context, poolId uint64, stakerAddress string, valaddress string) error

AssertValaccountAuthorized checks if the given `valaddress` is allowed to vote in pool with id `poolId` to vote in favor of `stakerAddress`. If the valaddress is not authorized the appropriate error is returned. Otherwise, it returns `nil`

func (Keeper) DoesLeavePoolEntryExistByIndex2

func (k Keeper) DoesLeavePoolEntryExistByIndex2(ctx sdk.Context, staker string, poolId uint64) bool

DoesLeavePoolEntryExistByIndex2 ...

func (Keeper) DoesStakerExist

func (k Keeper) DoesStakerExist(ctx sdk.Context, staker string) bool

DoesStakerExist returns true if the staker exists

func (Keeper) DoesValaccountExist

func (k Keeper) DoesValaccountExist(ctx sdk.Context, poolId uint64, stakerAddress string) bool

DoesValaccountExist only checks if the key is present in the KV-Store without loading and unmarshalling to full entry

func (Keeper) GetActiveStakers

func (k Keeper) GetActiveStakers(ctx sdk.Context) []string

GetActiveStakers returns all staker-addresses that are currently participating in at least one pool.

func (Keeper) GetActiveValidators

func (k Keeper) GetActiveValidators(ctx sdk.Context) (validators []interface{})

GetActiveValidators returns all protocol-node information which are needed by the governance to calculate the voting powers. The interface needs to correspond to github.com/cosmos/cosmos-sdk/x/gov/types/v1.ValidatorGovInfo But as there is no direct dependency in the cosmos-sdk-fork this value is passed as an interface{}

func (Keeper) GetAllCommissionChangeEntries

func (k Keeper) GetAllCommissionChangeEntries(ctx sdk.Context) (list []types.CommissionChangeEntry)

GetAllCommissionChangeEntries returns all pending commission change entries of all stakers

func (Keeper) GetAllLeavePoolEntries

func (k Keeper) GetAllLeavePoolEntries(ctx sdk.Context) (list []types.LeavePoolEntry)

GetAllLeavePoolEntries ...

func (Keeper) GetAllStakerAddressesOfPool

func (k Keeper) GetAllStakerAddressesOfPool(ctx sdk.Context, poolId uint64) (stakers []string)

GetAllStakerAddressesOfPool returns a list of all stakers which have currently a valaccount registered for the given pool and are therefore allowed to participate in that pool.

func (Keeper) GetAllStakers

func (k Keeper) GetAllStakers(ctx sdk.Context) (list []types.Staker)

GetAllStakers returns all staker

func (Keeper) GetAllValaccounts

func (k Keeper) GetAllValaccounts(ctx sdk.Context) (list []types.Valaccount)

GetAllValaccounts ...

func (Keeper) GetAllValaccountsOfPool

func (k Keeper) GetAllValaccountsOfPool(ctx sdk.Context, poolId uint64) (val []*types.Valaccount)

GetAllValaccountsOfPool returns a list of all valaccount

func (Keeper) GetCommission

func (k Keeper) GetCommission(ctx sdk.Context, stakerAddress string) sdk.Dec

GetCommission returns the commission of a staker as a parsed sdk.Dec

func (Keeper) GetCommissionChangeEntry

func (k Keeper) GetCommissionChangeEntry(ctx sdk.Context, index uint64) (val types.CommissionChangeEntry, found bool)

GetCommissionChangeEntry ...

func (Keeper) GetCommissionChangeEntryByIndex2

func (k Keeper) GetCommissionChangeEntryByIndex2(ctx sdk.Context, staker string) (val types.CommissionChangeEntry, found bool)

GetCommissionChangeEntryByIndex2 returns a pending commission change entry by staker address (if there is one)

func (Keeper) GetCommissionChangeTime

func (k Keeper) GetCommissionChangeTime(ctx sdk.Context) (res uint64)

GetCommissionChangeTime returns the CommissionChangeTime param

func (Keeper) GetDelegations

func (k Keeper) GetDelegations(ctx sdk.Context, delegator string) (validators []string, amounts []sdk.Dec)

GetDelegations returns the address and the delegation amount of all active protocol-stakers the delegator as delegated to. This is used to calculate the vote weight each delegator has.

func (Keeper) GetLeavePoolEntry

func (k Keeper) GetLeavePoolEntry(ctx sdk.Context, index uint64) (val types.LeavePoolEntry, found bool)

GetLeavePoolEntry ...

func (Keeper) GetLeavePoolEntryByIndex2

func (k Keeper) GetLeavePoolEntryByIndex2(ctx sdk.Context, staker string, poolId uint64) (val types.LeavePoolEntry, found bool)

GetLeavePoolEntryByIndex2 ...

func (Keeper) GetLeavePoolTime

func (k Keeper) GetLeavePoolTime(ctx sdk.Context) (res uint64)

GetLeavePoolTime returns the LeavePoolTime param

func (Keeper) GetPaginatedStakerQuery

func (k Keeper) GetPaginatedStakerQuery(
	ctx sdk.Context,
	pagination *query.PageRequest,
	accumulator func(staker types.Staker),
) (*query.PageResponse, error)

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams returns the current x/stakers module parameters.

func (Keeper) GetPoolCount

func (k Keeper) GetPoolCount(ctx sdk.Context, stakerAddress string) (poolCount uint64)

GetPoolCount returns the number of pools the current staker is currently participating.

func (Keeper) GetQueueState

func (k Keeper) GetQueueState(ctx sdk.Context, identifier types.QUEUE_IDENTIFIER) (state types.QueueState)

GetQueueState returns a queue state object based on the identifier as there are multiple queues present in the stakers module

func (Keeper) GetStaker

func (k Keeper) GetStaker(
	ctx sdk.Context,
	staker string,
) (val types.Staker, found bool)

GetStaker returns a staker from its index

func (Keeper) GetStakerCountOfPool

func (k Keeper) GetStakerCountOfPool(ctx sdk.Context, poolId uint64) uint64

func (Keeper) GetValaccount

func (k Keeper) GetValaccount(ctx sdk.Context, poolId uint64, stakerAddress string) (val types.Valaccount, found bool)

GetValaccount returns a Valaccount from its index

func (Keeper) GetValaccountsFromStaker

func (k Keeper) GetValaccountsFromStaker(ctx sdk.Context, stakerAddress string) (val []*types.Valaccount)

GetValaccountsFromStaker returns all pools the staker has valaccounts in

func (Keeper) IncreaseStakerCommissionRewards added in v1.3.0

func (k Keeper) IncreaseStakerCommissionRewards(ctx sdk.Context, address string, amount uint64) error

IncreaseStakerCommissionRewards sets the uploader's commission rewards and transfers the funds from the pool module to the stakers module, so the funds can be later claimed and transferred from here

func (Keeper) IncrementPoints

func (k Keeper) IncrementPoints(ctx sdk.Context, poolId uint64, stakerAddress string) uint64

IncrementPoints increments to Points for a staker in a given pool. Returns the amount of the current points (including the current incrementation)

func (Keeper) LeavePool

func (k Keeper) LeavePool(ctx sdk.Context, staker string, poolId uint64)

LeavePool removes a staker from a pool and emits the corresponding event. The staker is no longer able to participate in the given pool. All points the staker had in that pool are deleted.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) Params

func (Keeper) ProcessCommissionChangeQueue

func (k Keeper) ProcessCommissionChangeQueue(ctx sdk.Context)

ProcessCommissionChangeQueue checks the queue for entries which are due and can be executed. If this is the case, the new commission will be applied to the staker

func (Keeper) ProcessLeavePoolQueue

func (k Keeper) ProcessLeavePoolQueue(ctx sdk.Context)

ProcessLeavePoolQueue ...

func (Keeper) RemoveCommissionChangeEntry

func (k Keeper) RemoveCommissionChangeEntry(ctx sdk.Context, commissionChangeEntry *types.CommissionChangeEntry)

RemoveCommissionChangeEntry ...

func (Keeper) RemoveLeavePoolEntry

func (k Keeper) RemoveLeavePoolEntry(ctx sdk.Context, leavePoolEntry *types.LeavePoolEntry)

RemoveLeavePoolEntry ...

func (Keeper) RemoveValaccountFromPool

func (k Keeper) RemoveValaccountFromPool(ctx sdk.Context, poolId uint64, stakerAddress string)

RemoveValaccountFromPool removes a valaccount from a given pool and updates all aggregated variables. If the valaccount is not in the pool nothing happens.

func (Keeper) ResetPoints

func (k Keeper) ResetPoints(ctx sdk.Context, poolId uint64, stakerAddress string) (previousPoints uint64)

ResetPoints sets the point count for the staker in the given pool back to zero. Returns the amount of points the staker had before the reset.

func (Keeper) SetCommissionChangeEntry

func (k Keeper) SetCommissionChangeEntry(ctx sdk.Context, commissionChangeEntry types.CommissionChangeEntry)

SetCommissionChangeEntry ...

func (Keeper) SetLeavePoolEntry

func (k Keeper) SetLeavePoolEntry(ctx sdk.Context, leavePoolEntry types.LeavePoolEntry)

SetLeavePoolEntry ...

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the x/stakers module parameters.

func (Keeper) SetQueueState

func (k Keeper) SetQueueState(ctx sdk.Context, identifier types.QUEUE_IDENTIFIER, state types.QueueState)

SetQueueState sets a endBlocker queue state based on the identifier. The identifier is used to distinguish between different queues.

func (Keeper) SetValaccount

func (k Keeper) SetValaccount(ctx sdk.Context, valaccount types.Valaccount)

SetValaccount set a specific Valaccount in the store from its index

func (Keeper) StoreKey

func (k Keeper) StoreKey() storetypes.StoreKey

func (Keeper) TotalBondedTokens

func (k Keeper) TotalBondedTokens(ctx sdk.Context) math.Int

TotalBondedTokens returns all tokens which are currently bonded by the protocol I.e. the sum of all delegation of all stakers that are currently participating in at least one pool

func (Keeper) UpdateStakerCommission

func (k Keeper) UpdateStakerCommission(ctx sdk.Context, address string, commission sdk.Dec)

UpdateStakerCommission ...

func (Keeper) UpdateStakerMetadata

func (k Keeper) UpdateStakerMetadata(
	ctx sdk.Context,
	address string,
	moniker string,
	website string,
	identity string,
	securityContact string,
	details string,
)

UpdateStakerMetadata ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL