keeper

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryOperator  = "operator"
	QueryOperators = "operators"
	QueryWithdraws = "withdraws"
	QueryTask      = "task"
	QueryResponse  = "response"
)

Variables

This section is empty.

Functions

func FundInvariant added in v2.7.0

func FundInvariant(k Keeper) sdk.Invariant

three invariants are checked

  1. sum of operator's collater should be equal to stored totalCollateral
  2. module account balance minus totalCollateral should be larger or equal to sum of operator's reward plus sum of pending task's bounty
  3. module account balance should be larger or equal to sum of operator's collateral plus sum of withdraw amount

func IDsInvariant added in v2.7.0

func IDsInvariant(k Keeper) sdk.Invariant

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewQuerier

func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

NewQuerier is the module level router for state queries.

func RegisterInvariants added in v2.7.0

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers all shield invariants.

func TasksInvariant added in v2.7.0

func TasksInvariant(k Keeper) sdk.Invariant

Types

type IDSet added in v2.7.0

type IDSet = map[string]struct{}

type Keeper

type Keeper struct {
	CertKeeper types.CertKeeper
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, storeKey sdk.StoreKey, authKeeper types.AccountKeeper, distriKeeper types.DistrKeeper,
	stakingKeeper types.StakingKeeper, bankKeeper types.BankKeeper, certKeeper types.CertKeeper, paramSpace types.ParamSubspace) Keeper

func (Keeper) AddCollateral

func (k Keeper) AddCollateral(ctx sdk.Context, address sdk.AccAddress, increment sdk.Coins) error

AddCollateral increases an operator's collateral, effective immediately.

func (Keeper) AddReward

func (k Keeper) AddReward(ctx sdk.Context, address sdk.AccAddress, increment sdk.Coins) error

AddReward increases an operators accumulated rewards.

func (Keeper) AddToClosingTaskIDs added in v2.7.0

func (k Keeper) AddToClosingTaskIDs(ctx sdk.Context, task types.TaskI)

AddToClosingTaskIDs sets the store of task IDs for aggregation on time.

func (Keeper) AddTotalCollateral

func (k Keeper) AddTotalCollateral(ctx sdk.Context, increment sdk.Coins) error

AddTotalCollateral increases total collateral.

func (Keeper) Aggregate

func (k Keeper) Aggregate(ctx sdk.Context, taskID []byte) error

Aggregate does an aggregation of responses for a task and updated task result.

func (Keeper) BuildTxTask added in v2.7.0

func (k Keeper) BuildTxTask(ctx sdk.Context, txHash []byte, creator string, bounty sdk.Coins, validTime time.Time) (types.TaskI, error)

func (Keeper) BuildTxTaskWithExpire added in v2.7.0

func (k Keeper) BuildTxTaskWithExpire(ctx sdk.Context, txHash []byte, creator string, bounty sdk.Coins, validTime time.Time, status types.TaskStatus) *types.TxTask

func (Keeper) CollectBounty

func (k Keeper) CollectBounty(ctx sdk.Context, value sdk.Coins, creator sdk.AccAddress) error

CollectBounty collects task bounty from the operator.

func (Keeper) CreateOperator

func (k Keeper) CreateOperator(ctx sdk.Context, address sdk.AccAddress, collateral sdk.Coins, proposer sdk.AccAddress, name string) error

CreateOperator creates an operator and deposits collateral.

func (Keeper) CreateTask

func (k Keeper) CreateTask(ctx sdk.Context, creator sdk.AccAddress, task types.TaskI) error

calling of CreateTask creates one of following 1. Task (smart contract task) 2. TxTask (transaction task) 3. placeholder TxTask (status:TaskStatusNil, creator: nil, bounty:nil)

func (Keeper) CreateWithdraw

func (k Keeper) CreateWithdraw(ctx sdk.Context, address sdk.AccAddress, amount sdk.Coins) error

CreateWithdraw creates a withdrawal.

func (Keeper) DeleteClosingTaskIDs

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

DeleteClosingTaskIDs deletes stores for task IDs closed at given block.

func (Keeper) DeleteExpiredTasks added in v2.7.0

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

delete tasks whose expiration >= BlockTime the taget task may already be gone due to explicitally removed by user

func (Keeper) DeleteFromClosingTaskIDs added in v2.7.0

func (k Keeper) DeleteFromClosingTaskIDs(ctx sdk.Context, task types.TaskI)

remove ID of the task from closingBlockStore because it has been handled in shortcut

func (Keeper) DeleteFromExpireIDs added in v2.7.0

func (k Keeper) DeleteFromExpireIDs(ctx sdk.Context, task types.TxTask)

func (Keeper) DeleteOperator

func (k Keeper) DeleteOperator(ctx sdk.Context, address sdk.AccAddress) error

DeleteOperators deletes an operator from store.

func (Keeper) DeleteShortcutTasks added in v2.7.0

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

func (Keeper) DeleteTask

func (k Keeper) DeleteTask(ctx sdk.Context, task types.TaskI) error

DeleteTask deletes a task from KVStore.

func (Keeper) DeleteWithdraw

func (k Keeper) DeleteWithdraw(ctx sdk.Context, address sdk.AccAddress, startTime int64) error

DeleteWithdraw deletes a withdrawal from store.

func (Keeper) DistributeBounty

func (k Keeper) DistributeBounty(ctx sdk.Context, task types.TaskI) error

DistributeBounty distributes bounty to operators based on responses and the aggregation result.

func (Keeper) FinalizeMatureWithdraws

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

FinalizeMatureWithdraws finishes mature (unlocked) withdrawals and removes them.

func (Keeper) FundCommunityPool

func (k Keeper) FundCommunityPool(ctx sdk.Context, amount sdk.Coins) error

FundCommunityPool transfers money from module account to community pool.

func (Keeper) GetAccountKeeper

func (k Keeper) GetAccountKeeper() types.AccountKeeper

GetAccountKeeper returns the auth keeper wrapped in module keeper.

func (Keeper) GetAllOperators

func (k Keeper) GetAllOperators(ctx sdk.Context) types.Operators

GetAllOperators gets all operators.

func (Keeper) GetAllTasks

func (k Keeper) GetAllTasks(ctx sdk.Context) (tasks []types.TaskI)

GetAllTasks gets all tasks.

func (Keeper) GetAllWithdraws

func (k Keeper) GetAllWithdraws(ctx sdk.Context) types.Withdraws

GetAllWithdraws gets all withdrawals from store.

func (Keeper) GetAllWithdrawsForExport

func (k Keeper) GetAllWithdrawsForExport(ctx sdk.Context) types.Withdraws

GetAllWithdrawsForExport gets all withdrawals from store and adjusts DueBlock value for import-export.

func (Keeper) GetClosingTaskIDs

func (k Keeper) GetClosingTaskIDs(ctx sdk.Context, task types.TaskI) (resIDs []types.TaskID)

GetClosingTaskIDs returns a list of task IDs by the closing block and valid time.

func (Keeper) GetClosingTaskIDsByHeight added in v2.7.0

func (k Keeper) GetClosingTaskIDsByHeight(ctx sdk.Context, blockHeight int64) []types.TaskID

func (Keeper) GetCollateralAmount

func (k Keeper) GetCollateralAmount(ctx sdk.Context, address sdk.AccAddress) (sdk.Int, error)

GetCollateralAmount gets an operator's collateral.

func (Keeper) GetInvalidTaskIDs added in v2.7.0

func (k Keeper) GetInvalidTaskIDs(ctx sdk.Context) (resIDs []types.TaskID)

func (Keeper) GetLockedPoolParams

func (k Keeper) GetLockedPoolParams(ctx sdk.Context) types.LockedPoolParams

GetLockedPoolParams gets the current locked pool params from the global param store.

func (Keeper) GetOperator

func (k Keeper) GetOperator(ctx sdk.Context, address sdk.AccAddress) (types.Operator, error)

GetOperator gets an operator from store.

func (Keeper) GetShortcutTasks added in v2.7.0

func (k Keeper) GetShortcutTasks(ctx sdk.Context) []types.TaskID

func (Keeper) GetTask

func (k Keeper) GetTask(ctx sdk.Context, taskID []byte) (task types.TaskI, err error)

GetTask returns a task given taskID.

func (Keeper) GetTaskIDsByTime added in v2.7.0

func (k Keeper) GetTaskIDsByTime(ctx sdk.Context, prefix []byte, theTime time.Time) []types.TaskID

func (Keeper) GetTaskParams

func (k Keeper) GetTaskParams(ctx sdk.Context) types.TaskParams

GetTaskParams gets the current task params from the global param store.

func (Keeper) GetTotalCollateral

func (k Keeper) GetTotalCollateral(ctx sdk.Context) (sdk.Coins, error)

GetTotalCollateral gets total collateral from store.

func (Keeper) HandleNoneTxTaskForResponse added in v2.7.0

func (k Keeper) HandleNoneTxTaskForResponse(ctx sdk.Context, txHash []byte) error

func (Keeper) IsBelowMinCollateral

func (k Keeper) IsBelowMinCollateral(ctx sdk.Context, currentCollateral sdk.Coins) bool

IsBelowMinCollateral determines if collateral is below the minimum requirement.

func (Keeper) IsOperator

func (k Keeper) IsOperator(ctx sdk.Context, address sdk.AccAddress) bool

IsOperator determines if an address belongs to an operator.

func (Keeper) IsValidResponse

func (k Keeper) IsValidResponse(ctx sdk.Context, task types.TaskI, response types.Response) error

IsValidResponse returns error if a response is not valid.

func (Keeper) IterateAllOperators

func (k Keeper) IterateAllOperators(ctx sdk.Context, callback func(operator types.Operator) (stop bool))

IterateAllOperators iterates all operators.

func (Keeper) IterateAllWithdraws

func (k Keeper) IterateAllWithdraws(ctx sdk.Context, callback func(withdraw types.Withdraw) (stop bool))

IterateAllWithdraws iterates all withdrawals in store.

func (Keeper) IterateMatureWithdraws

func (k Keeper) IterateMatureWithdraws(ctx sdk.Context, callback func(withdraw types.Withdraw) (stop bool))

IterateMatureWithdraws iterates all mature (unlocked) withdrawals in store.

func (Keeper) IteratorAllTasks

func (k Keeper) IteratorAllTasks(ctx sdk.Context, callback func(task types.TaskI) (stop bool))

IteratorAllTasks iterates over all the stored tasks and performs a callback function.

func (Keeper) IteratorTaskIDsByEndTime added in v2.7.0

func (k Keeper) IteratorTaskIDsByEndTime(ctx sdk.Context, prefix []byte, endTime time.Time, callback func(key, value []byte) (stop bool))

func (Keeper) Operator

Operator queries an operator based on its address.

func (Keeper) Operators

Operators queries all operators.

func (Keeper) Params added in v2.7.1

Params queries all params

func (Keeper) ReduceCollateral

func (k Keeper) ReduceCollateral(ctx sdk.Context, address sdk.AccAddress, decrement sdk.Coins) error

ReduceCollateral reduces an operator's collateral and creates a withdrawal for it.

func (Keeper) ReduceTotalCollateral

func (k Keeper) ReduceTotalCollateral(ctx sdk.Context, decrement sdk.Coins) error

ReduceTotalCollateral reduces total collateral.

func (Keeper) RefundBounty added in v2.7.0

func (k Keeper) RefundBounty(ctx sdk.Context, task types.TaskI) error

func (Keeper) RemoveOperator

func (k Keeper) RemoveOperator(ctx sdk.Context, operatorAddress, proposerAddress string) error

RemoveOperator removes an operator, creates an withdrawal for collateral and gives back rewards immediately.

func (Keeper) RemoveTask

func (k Keeper) RemoveTask(ctx sdk.Context, taskID []byte, force bool, deleter sdk.AccAddress) error

RemoveTask removes a task from kvstore if it is closed, expired and requested by its creator. The id of the removed task may still remain in the ExpireTaskIDsStore.

in such case, when it's expired, the unfound task will be simply skipped

func (Keeper) RespondToTask

func (k Keeper) RespondToTask(ctx sdk.Context, taskID []byte, score int64, operatorAddress sdk.AccAddress) error

RespondToTask records the response from an operator for a task.

func (Keeper) Response

Response queries a response based on its task contract, task function, and operator address.

func (Keeper) SaveExpireTxTask added in v2.7.0

func (k Keeper) SaveExpireTxTask(ctx sdk.Context, task *types.TxTask)

func (Keeper) SetClosingTaskIDs added in v2.7.0

func (k Keeper) SetClosingTaskIDs(ctx sdk.Context, task types.TaskI, taskIDs []types.TaskID)

func (Keeper) SetLockedPoolParams

func (k Keeper) SetLockedPoolParams(ctx sdk.Context, poolParams types.LockedPoolParams)

SetLockedPoolParams sets the current locked pool params to the global param store.

func (Keeper) SetOperator

func (k Keeper) SetOperator(ctx sdk.Context, operator types.Operator)

SetOperator sets an operator to store.

func (Keeper) SetShortcutTasks added in v2.7.0

func (k Keeper) SetShortcutTasks(ctx sdk.Context, tid []byte)

func (Keeper) SetTask

func (k Keeper) SetTask(ctx sdk.Context, task types.TaskI)

SetTask sets a task in KVStore.

func (Keeper) SetTaskParams

func (k Keeper) SetTaskParams(ctx sdk.Context, taskParams types.TaskParams)

SetTaskParams sets the current task params to the global param store.

func (Keeper) SetTotalCollateral

func (k Keeper) SetTotalCollateral(ctx sdk.Context, collateral sdk.Coins)

SetTotalCollateral sets total collateral to store.

func (Keeper) SetTxTask added in v2.7.0

func (k Keeper) SetTxTask(ctx sdk.Context, task *types.TxTask)

func (Keeper) SetWithdraw

func (k Keeper) SetWithdraw(ctx sdk.Context, withdraw types.Withdraw)

SetWithdraw sets a withdrawal in store.

func (Keeper) Task

Task queries a task given its contract and function.

func (Keeper) TotalValidTaskCollateral

func (k Keeper) TotalValidTaskCollateral(ctx sdk.Context, task types.TaskI) sdk.Int

TotalValidTaskCollateral calculates the total amount of valid collateral of a task.

func (Keeper) TryShortcut added in v2.7.0

func (k Keeper) TryShortcut(ctx sdk.Context, task types.TaskI)

func (Keeper) TxResponse added in v2.7.0

TxResponse queries a tx response based on its tx hash, and operator address.

func (Keeper) TxTask added in v2.7.0

TxTask queries a tx task given its tx hash.

func (Keeper) UpdateAndGetAllTasks

func (k Keeper) UpdateAndGetAllTasks(ctx sdk.Context) (tasks []types.Task, txTasks []types.TxTask)

UpdateAndGetAllTasks updates all tasks and returns them.

func (Keeper) UpdateAndSetTask

func (k Keeper) UpdateAndSetTask(ctx sdk.Context, task *types.Task)

UpdateAndSetTask updates a task and set it in KVStore.

func (Keeper) WithdrawAllReward

func (k Keeper) WithdrawAllReward(ctx sdk.Context, address sdk.AccAddress) (sdk.Coins, error)

WithdrawAllReward gives back all rewards of an operator.

func (Keeper) Withdraws

Withdraws queries all withdraws.

type Migrator added in v2.7.0

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator added in v2.7.0

func NewMigrator(keeper Keeper) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2 added in v2.7.0

func (m Migrator) Migrate1to2(ctx sdk.Context) error

Migrate1to2 migrates from version 1 to 2.

Jump to

Keyboard shortcuts

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