keeper

package
v0.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecuteByIncentiveTypeCB

type ExecuteByIncentiveTypeCB func(incentive types.Incentive) (types.Incentive, error)

ExecuteByIncentiveTypeCB is a callback function that can utilized to update all incentives of a given type. This is useful for having incentive/strategy pairs that are meant to last several blocks. This function should return the updated incentive, or nil if the incentive should be deleted.

type Keeper

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

Keeper is the base keeper for the x/incentives module.

func NewKeeper

func NewKeeper(
	sk storetypes.StoreKey,
	incentiveStrategies map[types.Incentive]types.Strategy,
) Keeper

NewKeeper constructs a new keeper from a store-key and a given set of (incentive, strategies) pairings. Note, if the strategies map is empty, then the keeper will not be able to process any incentives. This must be set by the application developer. Each incentive type must have a corresponding strategy function.

func (Keeper) AddIncentives

func (k Keeper) AddIncentives(ctx sdk.Context, incentives []types.Incentive) error

AddIncentives adds a set of incentives to the module's state.

func (Keeper) ExecuteByIncentiveType

func (k Keeper) ExecuteByIncentiveType(
	ctx sdk.Context,
	incentive types.Incentive,
	cb ExecuteByIncentiveTypeCB,
) error

ExecuteByIncentiveType updates all incentives of a given type.

func (Keeper) ExecuteIncentiveStrategy

func (k Keeper) ExecuteIncentiveStrategy(
	ctx sdk.Context,
	incentive types.Incentive,
	strategy types.Strategy,
) error

ExecuteIncentiveStrategy executes a given strategy for all incentives of a given type. Note that the strategy may mutate the incentive, and return a new incentive to be stored. Stategies must return nil if the incentive should be deleted. Otherwise, the incentive will be updated.

func (Keeper) ExecuteStrategies

func (k Keeper) ExecuteStrategies(ctx sdk.Context) error

ExecuteStrategies executes all of the strategies with the stored incentives.

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

ExportGenesis returns the current store state as a genesis state. Note, that if any of the incentive types have no entries in the store, they will not be included in the genesis state.

func (Keeper) GetIncentivesByType

func (k Keeper) GetIncentivesByType(ctx sdk.Context, incentive types.Incentive) ([]types.Incentive, error)

GetIncentivesByType returns all incentives of a given type.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState)

InitGenesis initializes the store state from a genesis state. Note, that all of the incentive types (e.g. badprice, goodprice) must be registered with the keeper in order for this to execute successfully.

func (Keeper) RemoveIncentivesByType

func (k Keeper) RemoveIncentivesByType(ctx sdk.Context, incentive types.Incentive) error

RemoveIncentivesByType removes all incentives of a given type from the module's state.

type QueryServer

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

QueryServer is the default implementation of the x/incentives QueryServer.

func NewQueryServer

func NewQueryServer(k Keeper) QueryServer

NewQueryServer returns an implementation of the x/incentives QueryServer.

func (QueryServer) GetAllIncentives

GetAllIncentives returns all incentives currently stored in the module.

func (QueryServer) GetIncentivesByType

GetIncentivesByType returns all incentives of a given type currently stored in the incentives module. If the type is not registered with the module, an error is returned.

Jump to

Keyboard shortcuts

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