Documentation ¶
Index ¶
- Constants
- func FundInvariant(k Keeper) sdk.Invariant
- func IDsInvariant(k Keeper) sdk.Invariant
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
- func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)
- func TasksInvariant(k Keeper) sdk.Invariant
- type IDSet
- type Keeper
- func (k Keeper) AddCollateral(ctx sdk.Context, address sdk.AccAddress, increment sdk.Coins) error
- func (k Keeper) AddReward(ctx sdk.Context, address sdk.AccAddress, increment sdk.Coins) error
- func (k Keeper) AddToClosingTaskIDs(ctx sdk.Context, task types.TaskI)
- func (k Keeper) AddTotalCollateral(ctx sdk.Context, increment sdk.Coins) error
- func (k Keeper) Aggregate(ctx sdk.Context, taskID []byte) error
- func (k Keeper) BuildTxTask(ctx sdk.Context, txHash []byte, creator string, bounty sdk.Coins, ...) (types.TaskI, error)
- func (k Keeper) BuildTxTaskWithExpire(ctx sdk.Context, txHash []byte, creator string, bounty sdk.Coins, ...) *types.TxTask
- func (k Keeper) CollectBounty(ctx sdk.Context, value sdk.Coins, creator sdk.AccAddress) error
- func (k Keeper) CreateOperator(ctx sdk.Context, address sdk.AccAddress, collateral sdk.Coins, ...) error
- func (k Keeper) CreateTask(ctx sdk.Context, creator sdk.AccAddress, task types.TaskI) error
- func (k Keeper) CreateWithdraw(ctx sdk.Context, address sdk.AccAddress, amount sdk.Coins) error
- func (k Keeper) DeleteClosingTaskIDs(ctx sdk.Context)
- func (k Keeper) DeleteExpiredTasks(ctx sdk.Context)
- func (k Keeper) DeleteFromClosingTaskIDs(ctx sdk.Context, task types.TaskI)
- func (k Keeper) DeleteFromExpireIDs(ctx sdk.Context, task types.TxTask)
- func (k Keeper) DeleteOperator(ctx sdk.Context, address sdk.AccAddress) error
- func (k Keeper) DeleteShortcutTasks(ctx sdk.Context)
- func (k Keeper) DeleteTask(ctx sdk.Context, task types.TaskI) error
- func (k Keeper) DeleteWithdraw(ctx sdk.Context, address sdk.AccAddress, startTime int64) error
- func (k Keeper) DistributeBounty(ctx sdk.Context, task types.TaskI) error
- func (k Keeper) FinalizeMatureWithdraws(ctx sdk.Context)
- func (k Keeper) FundCommunityPool(ctx sdk.Context, amount sdk.Coins) error
- func (k Keeper) GetAccountKeeper() types.AccountKeeper
- func (k Keeper) GetAllOperators(ctx sdk.Context) types.Operators
- func (k Keeper) GetAllTasks(ctx sdk.Context) (tasks []types.TaskI)
- func (k Keeper) GetAllWithdraws(ctx sdk.Context) types.Withdraws
- func (k Keeper) GetAllWithdrawsForExport(ctx sdk.Context) types.Withdraws
- func (k Keeper) GetClosingTaskIDs(ctx sdk.Context, task types.TaskI) (resIDs []types.TaskID)
- func (k Keeper) GetClosingTaskIDsByHeight(ctx sdk.Context, blockHeight int64) []types.TaskID
- func (k Keeper) GetCollateralAmount(ctx sdk.Context, address sdk.AccAddress) (sdk.Int, error)
- func (k Keeper) GetInvalidTaskIDs(ctx sdk.Context) (resIDs []types.TaskID)
- func (k Keeper) GetLockedPoolParams(ctx sdk.Context) types.LockedPoolParams
- func (k Keeper) GetOperator(ctx sdk.Context, address sdk.AccAddress) (types.Operator, error)
- func (k Keeper) GetShortcutTasks(ctx sdk.Context) []types.TaskID
- func (k Keeper) GetTask(ctx sdk.Context, taskID []byte) (task types.TaskI, err error)
- func (k Keeper) GetTaskIDsByTime(ctx sdk.Context, prefix []byte, theTime time.Time) []types.TaskID
- func (k Keeper) GetTaskParams(ctx sdk.Context) types.TaskParams
- func (k Keeper) GetTotalCollateral(ctx sdk.Context) (sdk.Coins, error)
- func (k Keeper) HandleNoneTxTaskForResponse(ctx sdk.Context, txHash []byte) error
- func (k Keeper) IsBelowMinCollateral(ctx sdk.Context, currentCollateral sdk.Coins) bool
- func (k Keeper) IsOperator(ctx sdk.Context, address sdk.AccAddress) bool
- func (k Keeper) IsValidResponse(ctx sdk.Context, task types.TaskI, response types.Response) error
- func (k Keeper) IterateAllOperators(ctx sdk.Context, callback func(operator types.Operator) (stop bool))
- func (k Keeper) IterateAllWithdraws(ctx sdk.Context, callback func(withdraw types.Withdraw) (stop bool))
- func (k Keeper) IterateMatureWithdraws(ctx sdk.Context, callback func(withdraw types.Withdraw) (stop bool))
- func (k Keeper) IteratorAllTasks(ctx sdk.Context, callback func(task types.TaskI) (stop bool))
- func (k Keeper) IteratorTaskIDsByEndTime(ctx sdk.Context, prefix []byte, endTime time.Time, ...)
- func (q Keeper) Operator(c context.Context, req *types.QueryOperatorRequest) (*types.QueryOperatorResponse, error)
- func (q Keeper) Operators(c context.Context, req *types.QueryOperatorsRequest) (*types.QueryOperatorsResponse, error)
- func (q Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) ReduceCollateral(ctx sdk.Context, address sdk.AccAddress, decrement sdk.Coins) error
- func (k Keeper) ReduceTotalCollateral(ctx sdk.Context, decrement sdk.Coins) error
- func (k Keeper) RefundBounty(ctx sdk.Context, task types.TaskI) error
- func (k Keeper) RemoveOperator(ctx sdk.Context, operatorAddress, proposerAddress string) error
- func (k Keeper) RemoveTask(ctx sdk.Context, taskID []byte, force bool, deleter sdk.AccAddress) error
- func (k Keeper) RespondToTask(ctx sdk.Context, taskID []byte, score int64, operatorAddress sdk.AccAddress) error
- func (q Keeper) Response(c context.Context, req *types.QueryResponseRequest) (*types.QueryResponseResponse, error)
- func (k Keeper) SaveExpireTxTask(ctx sdk.Context, task *types.TxTask)
- func (k Keeper) SetClosingTaskIDs(ctx sdk.Context, task types.TaskI, taskIDs []types.TaskID)
- func (k Keeper) SetLockedPoolParams(ctx sdk.Context, poolParams types.LockedPoolParams)
- func (k Keeper) SetOperator(ctx sdk.Context, operator types.Operator)
- func (k Keeper) SetShortcutTasks(ctx sdk.Context, tid []byte)
- func (k Keeper) SetTask(ctx sdk.Context, task types.TaskI)
- func (k Keeper) SetTaskParams(ctx sdk.Context, taskParams types.TaskParams)
- func (k Keeper) SetTotalCollateral(ctx sdk.Context, collateral sdk.Coins)
- func (k Keeper) SetTxTask(ctx sdk.Context, task *types.TxTask)
- func (k Keeper) SetWithdraw(ctx sdk.Context, withdraw types.Withdraw)
- func (q Keeper) Task(c context.Context, req *types.QueryTaskRequest) (*types.QueryTaskResponse, error)
- func (k Keeper) TotalValidTaskCollateral(ctx sdk.Context, task types.TaskI) sdk.Int
- func (k Keeper) TryShortcut(ctx sdk.Context, task types.TaskI)
- func (q Keeper) TxResponse(c context.Context, req *types.QueryTxResponseRequest) (*types.QueryTxResponseResponse, error)
- func (q Keeper) TxTask(c context.Context, req *types.QueryTxTaskRequest) (*types.QueryTxTaskResponse, error)
- func (k Keeper) UpdateAndGetAllTasks(ctx sdk.Context) (tasks []types.Task, txTasks []types.TxTask)
- func (k Keeper) UpdateAndSetTask(ctx sdk.Context, task *types.Task)
- func (k Keeper) WithdrawAllReward(ctx sdk.Context, address sdk.AccAddress) (sdk.Coins, error)
- func (q Keeper) Withdraws(c context.Context, req *types.QueryWithdrawsRequest) (*types.QueryWithdrawsResponse, error)
- type Migrator
Constants ¶
const ( QueryOperator = "operator" QueryOperators = "operators" QueryWithdraws = "withdraws" QueryTask = "task" QueryResponse = "response" )
Variables ¶
This section is empty.
Functions ¶
func FundInvariant ¶ added in v2.7.0
three invariants are checked
- sum of operator's collater should be equal to stored totalCollateral
- module account balance minus totalCollateral should be larger or equal to sum of operator's reward plus sum of pending task's bounty
- 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 NewMsgServerImpl ¶
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
Types ¶
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 ¶
AddCollateral increases an operator's collateral, effective immediately.
func (Keeper) AddToClosingTaskIDs ¶ added in v2.7.0
AddToClosingTaskIDs sets the store of task IDs for aggregation on time.
func (Keeper) AddTotalCollateral ¶
AddTotalCollateral increases total collateral.
func (Keeper) Aggregate ¶
Aggregate does an aggregation of responses for a task and updated task result.
func (Keeper) BuildTxTask ¶ added in v2.7.0
func (Keeper) BuildTxTaskWithExpire ¶ added in v2.7.0
func (Keeper) CollectBounty ¶
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 ¶
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 ¶
CreateWithdraw creates a withdrawal.
func (Keeper) DeleteClosingTaskIDs ¶
DeleteClosingTaskIDs deletes stores for task IDs closed at given block.
func (Keeper) DeleteExpiredTasks ¶ added in v2.7.0
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
remove ID of the task from closingBlockStore because it has been handled in shortcut
func (Keeper) DeleteFromExpireIDs ¶ added in v2.7.0
func (Keeper) DeleteOperator ¶
DeleteOperators deletes an operator from store.
func (Keeper) DeleteShortcutTasks ¶ added in v2.7.0
func (Keeper) DeleteTask ¶
DeleteTask deletes a task from KVStore.
func (Keeper) DeleteWithdraw ¶
DeleteWithdraw deletes a withdrawal from store.
func (Keeper) DistributeBounty ¶
DistributeBounty distributes bounty to operators based on responses and the aggregation result.
func (Keeper) FinalizeMatureWithdraws ¶
FinalizeMatureWithdraws finishes mature (unlocked) withdrawals and removes them.
func (Keeper) FundCommunityPool ¶
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 ¶
GetAllOperators gets all operators.
func (Keeper) GetAllTasks ¶
GetAllTasks gets all tasks.
func (Keeper) GetAllWithdraws ¶
GetAllWithdraws gets all withdrawals from store.
func (Keeper) GetAllWithdrawsForExport ¶
GetAllWithdrawsForExport gets all withdrawals from store and adjusts DueBlock value for import-export.
func (Keeper) GetClosingTaskIDs ¶
GetClosingTaskIDs returns a list of task IDs by the closing block and valid time.
func (Keeper) GetClosingTaskIDsByHeight ¶ added in v2.7.0
func (Keeper) GetCollateralAmount ¶
GetCollateralAmount gets an operator's collateral.
func (Keeper) GetInvalidTaskIDs ¶ added in v2.7.0
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 ¶
GetOperator gets an operator from store.
func (Keeper) GetShortcutTasks ¶ added in v2.7.0
func (Keeper) GetTaskIDsByTime ¶ added in v2.7.0
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 ¶
GetTotalCollateral gets total collateral from store.
func (Keeper) HandleNoneTxTaskForResponse ¶ added in v2.7.0
func (Keeper) IsBelowMinCollateral ¶
IsBelowMinCollateral determines if collateral is below the minimum requirement.
func (Keeper) IsOperator ¶
IsOperator determines if an address belongs to an operator.
func (Keeper) IsValidResponse ¶
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 ¶
IteratorAllTasks iterates over all the stored tasks and performs a callback function.
func (Keeper) IteratorTaskIDsByEndTime ¶ added in v2.7.0
func (Keeper) Operator ¶
func (q Keeper) Operator(c context.Context, req *types.QueryOperatorRequest) (*types.QueryOperatorResponse, error)
Operator queries an operator based on its address.
func (Keeper) Operators ¶
func (q Keeper) Operators(c context.Context, req *types.QueryOperatorsRequest) (*types.QueryOperatorsResponse, error)
Operators queries all operators.
func (Keeper) Params ¶ added in v2.7.1
func (q Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
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 ¶
ReduceTotalCollateral reduces total collateral.
func (Keeper) RefundBounty ¶ added in v2.7.0
func (Keeper) RemoveOperator ¶
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 ¶
func (q Keeper) Response(c context.Context, req *types.QueryResponseRequest) (*types.QueryResponseResponse, error)
Response queries a response based on its task contract, task function, and operator address.
func (Keeper) SaveExpireTxTask ¶ added in v2.7.0
func (Keeper) SetClosingTaskIDs ¶ added in v2.7.0
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 ¶
SetOperator sets an operator to store.
func (Keeper) SetShortcutTasks ¶ added in v2.7.0
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 ¶
SetTotalCollateral sets total collateral to store.
func (Keeper) SetWithdraw ¶
SetWithdraw sets a withdrawal in store.
func (Keeper) Task ¶
func (q Keeper) Task(c context.Context, req *types.QueryTaskRequest) (*types.QueryTaskResponse, error)
Task queries a task given its contract and function.
func (Keeper) TotalValidTaskCollateral ¶
TotalValidTaskCollateral calculates the total amount of valid collateral of a task.
func (Keeper) TryShortcut ¶ added in v2.7.0
func (Keeper) TxResponse ¶ added in v2.7.0
func (q Keeper) TxResponse(c context.Context, req *types.QueryTxResponseRequest) (*types.QueryTxResponseResponse, error)
TxResponse queries a tx response based on its tx hash, and operator address.
func (Keeper) TxTask ¶ added in v2.7.0
func (q Keeper) TxTask(c context.Context, req *types.QueryTxTaskRequest) (*types.QueryTxTaskResponse, error)
TxTask queries a tx task given its tx hash.
func (Keeper) UpdateAndGetAllTasks ¶
UpdateAndGetAllTasks updates all tasks and returns them.
func (Keeper) UpdateAndSetTask ¶
UpdateAndSetTask updates a task and set it in KVStore.
func (Keeper) WithdrawAllReward ¶
WithdrawAllReward gives back all rewards of an operator.
func (Keeper) Withdraws ¶
func (q Keeper) Withdraws(c context.Context, req *types.QueryWithdrawsRequest) (*types.QueryWithdrawsResponse, error)
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
NewMigrator returns a new Migrator.