types

package
v0.0.0-...-f2ae4c7 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeWithdraw      = "withdraw_reward"
	EventTypeCreateTask    = "create_task"
	EventTypeRespondToTask = "respond_to_task"
	EventTypeInquireTask   = "inquire_task"
	EventTypeDeleteTask    = "delete_a_task"
)
View Source
const (
	// ModuleName is the name of this module
	ModuleName = "oracle"

	// RouterKey is used to route messages.
	RouterKey = ModuleName

	// StoreKey is the prefix under which we store this module's data.
	StoreKey = ModuleName

	// QuerierRoute is used to handle abci_query requests.
	QuerierRoute = ModuleName
)
View Source
const (
	TaskStatusNil = iota
	TaskStatusPending
	TaskStatusSucceeded
	TaskStatusFailed
)

Variables

View Source
var (
	ErrNoOperatorFound         = sdkerrors.Register(ModuleName, 101, "no operator was found")
	ErrOperatorAlreadyExists   = sdkerrors.Register(ModuleName, 102, "operator already exists")
	ErrInvalidDueBlock         = sdkerrors.Register(ModuleName, 103, "invalid due block")
	ErrNoTotalCollateralFound  = sdkerrors.Register(ModuleName, 104, "total collateral not found")
	ErrNoEnoughTotalCollateral = sdkerrors.Register(ModuleName, 105, "total collateral not enough")
	ErrTotalCollateralNotEqual = sdkerrors.Register(ModuleName, 106, "total collateral not equal")
	ErrNoEnoughCollateral      = sdkerrors.Register(ModuleName, 107, "collateral not enough")
	ErrInvalidPoolParams       = sdkerrors.Register(ModuleName, 108, "invalid pool params")
	ErrInvalidTaskParams       = sdkerrors.Register(ModuleName, 109, "invalid task params")

	ErrTaskNotExists       = sdkerrors.Register(ModuleName, 201, "task does not exist")
	ErrUnqualifiedOperator = sdkerrors.Register(ModuleName, 202, "operator is not qualified")
	ErrDuplicateResponse   = sdkerrors.Register(ModuleName, 203, "already receive response from this operator")
	ErrTaskClosed          = sdkerrors.Register(ModuleName, 204, "task is already closed")
	ErrTaskNotClosed       = sdkerrors.Register(ModuleName, 205, "task has not been closed")
	ErrNotExpired          = sdkerrors.Register(ModuleName, 206, "task is not expired")
	ErrNotCreator          = sdkerrors.Register(ModuleName, 207, "only creator is allowed to perform this action")
	ErrNotFinished         = sdkerrors.Register(ModuleName, 208, "the task is on going")
	ErrTaskFailed          = sdkerrors.Register(ModuleName, 209, "task failed")
	ErrInvalidScore        = sdkerrors.Register(ModuleName, 210, "invalid score")
)
View Source
var (
	OperatorStoreKeyPrefix    = []byte{0x01}
	WithdrawStoreKeyPrefix    = []byte{0x02}
	TotalCollateralKeyPrefix  = []byte{0x03}
	TaskStoreKeyPrefix        = []byte{0x04}
	ClosingTaskStoreKeyPrefix = []byte{0x05}
)
View Source
var (
	ParamsStoreKeyTaskParams = []byte("taskparams")
	ParamsStoreKeyPoolParams = []byte("poolparams")
)
View Source
var (
	DefaultExpirationDuration = time.Duration(24) * time.Hour
	DefaultAggregationWindow  = int64(20)
	DefaultAggregationResult  = sdk.NewInt(1)
	DefaultEpsilon1           = sdk.NewInt(1)
	DefaultEpsilon2           = sdk.NewInt(100)
	DefaultThresholdScore     = sdk.NewInt(128)

	DefaultLockedInBlocks    = int64(30)
	DefaultMinimumCollateral = int64(50000)
)

Default parameters

View Source
var ModuleCdc *codec.Codec

ModuleCdc is a generic sealed codec to be used throughout this module.

Functions

func ClosingTaskIDsStoreKey

func ClosingTaskIDsStoreKey(blockHeight int64) []byte

func OperatorStoreKey

func OperatorStoreKey(operator sdk.AccAddress) []byte

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable is the key declaration for parameters.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec.

func TaskStoreKey

func TaskStoreKey(contract, function string) []byte

func TotalCollateralKey

func TotalCollateralKey() []byte

func ValidateGenesis

func ValidateGenesis(bz json.RawMessage) error

ValidateGenesis validates oracle genesis data.

func WithdrawStoreKey

func WithdrawStoreKey(address sdk.AccAddress, startTime int64) []byte

Types

type AuthKeeper

type AuthKeeper interface {
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) exported.Account
}

type DistrKeeper

type DistrKeeper interface {
	FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error
}

type GenesisState

type GenesisState struct {
	Operators       []Operator       `json:"operators"`
	TotalCollateral sdk.Coins        `json:"total_collateral"`
	PoolParams      LockedPoolParams `json:"pool_params"`
	TaskParams      TaskParams       `json:"task_params"`
	Withdraws       []Withdraw       `json:"withdraws"`
	Tasks           []Task           `json:"tasks"`
}

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState creates a default GenesisState object.

func NewGenesisState

func NewGenesisState(operators []Operator, totalCollateral sdk.Coins, poolParams LockedPoolParams, taskParams TaskParams,
	withdraws []Withdraw, tasks []Task) GenesisState

NewGenesisState constructs a GenesisState object.

type LockedPoolParams

type LockedPoolParams struct {
	LockedInBlocks    int64 `json:"locked_in_blocks"`
	MinimumCollateral int64 `json:"minimum_collateral"`
}

func DefaultLockedPoolParams

func DefaultLockedPoolParams() LockedPoolParams

DefaultLockedPoolParams generates default set for LockedPoolParams

func NewLockedPoolParams

func NewLockedPoolParams(lockedInBlocks, minimumCollateral int64) LockedPoolParams

NewLockedPoolParams returns a LockedPoolParams object.

type MsgAddCollateral

type MsgAddCollateral struct {
	Address             sdk.AccAddress
	CollateralIncrement sdk.Coins
}

func NewMsgAddCollateral

func NewMsgAddCollateral(address sdk.AccAddress, increment sdk.Coins) MsgAddCollateral

NewMsgAddCollateral returns the message for adding collateral.

func (MsgAddCollateral) GetSignBytes

func (m MsgAddCollateral) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgAddCollateral) GetSigners

func (m MsgAddCollateral) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgAddCollateral) Route

func (MsgAddCollateral) Route() string

Route returns the module name.

func (MsgAddCollateral) Type

func (MsgAddCollateral) Type() string

Type returns the action name.

func (MsgAddCollateral) ValidateBasic

func (m MsgAddCollateral) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgCreateOperator

type MsgCreateOperator struct {
	Address    sdk.AccAddress
	Collateral sdk.Coins
	Proposer   sdk.AccAddress
	Name       string
}

func NewMsgCreateOperator

func NewMsgCreateOperator(address sdk.AccAddress, collateral sdk.Coins, proposer sdk.AccAddress, name string) MsgCreateOperator

NewMsgCreateOperator returns the message for creating an operator.

func (MsgCreateOperator) GetSignBytes

func (m MsgCreateOperator) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgCreateOperator) GetSigners

func (m MsgCreateOperator) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgCreateOperator) Route

func (MsgCreateOperator) Route() string

Route returns the module name.

func (MsgCreateOperator) Type

func (MsgCreateOperator) Type() string

Type returns the action name.

func (MsgCreateOperator) ValidateBasic

func (m MsgCreateOperator) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgCreateTask

type MsgCreateTask struct {
	Contract    string
	Function    string
	Bounty      sdk.Coins
	Description string
	Expiration  time.Time
	Creator     sdk.AccAddress
	Wait        int64
}

MsgCreateTask is the message for creating a task.

func NewMsgCreateTask

func NewMsgCreateTask(contract, function string, bounty sdk.Coins, description string,
	expiration time.Time, creator sdk.AccAddress, wait int64) MsgCreateTask

NewMsgCreateTask returns a new message for creating a task.

func (MsgCreateTask) GetSignBytes

func (m MsgCreateTask) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgCreateTask) GetSigners

func (m MsgCreateTask) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgCreateTask) Route

func (MsgCreateTask) Route() string

Route returns the module name.

func (MsgCreateTask) Type

func (MsgCreateTask) Type() string

Type returns the action name.

func (MsgCreateTask) ValidateBasic

func (m MsgCreateTask) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgDeleteTask

type MsgDeleteTask struct {
	Contract string
	Function string
	Force    bool
	Deleter  sdk.AccAddress
}

MsgDeleteTask is the msg type for delete a task.

func NewMsgDeleteTask

func NewMsgDeleteTask(contract, function string, force bool, deleter sdk.AccAddress) MsgDeleteTask

NewMsgDeleteTask returns a new MsgDeleteTask instance.

func (MsgDeleteTask) GetSignBytes

func (m MsgDeleteTask) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgDeleteTask) GetSigners

func (m MsgDeleteTask) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgDeleteTask) Route

func (MsgDeleteTask) Route() string

Route returns the module name.

func (MsgDeleteTask) Type

func (MsgDeleteTask) Type() string

Type returns the action name.

func (MsgDeleteTask) ValidateBasic

func (m MsgDeleteTask) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgInquiryTask

type MsgInquiryTask struct {
	Contract string
	Function string
	TxHash   string
	Inquirer sdk.AccAddress
}

MsgInquiryTask is the message for inquiry a task.

func NewMsgInquiryTask

func NewMsgInquiryTask(contract, function, txhash string, inquirer sdk.AccAddress) MsgInquiryTask

NewMsgInquiryTask returns a new MsgInquiryTask instance.

func (MsgInquiryTask) GetSignBytes

func (m MsgInquiryTask) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgInquiryTask) GetSigners

func (m MsgInquiryTask) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgInquiryTask) Route

func (MsgInquiryTask) Route() string

Route returns the module name.

func (MsgInquiryTask) Type

func (MsgInquiryTask) Type() string

Type returns the action name.

func (MsgInquiryTask) ValidateBasic

func (m MsgInquiryTask) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgReduceCollateral

type MsgReduceCollateral struct {
	Address             sdk.AccAddress
	CollateralDecrement sdk.Coins
}

func NewMsgReduceCollateral

func NewMsgReduceCollateral(address sdk.AccAddress, decrement sdk.Coins) MsgReduceCollateral

NewMsgReduceCollateral returns the message for reducing collateral.

func (MsgReduceCollateral) GetSignBytes

func (m MsgReduceCollateral) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgReduceCollateral) GetSigners

func (m MsgReduceCollateral) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgReduceCollateral) Route

func (MsgReduceCollateral) Route() string

Route returns the module name.

func (MsgReduceCollateral) Type

func (MsgReduceCollateral) Type() string

Type returns the action name.

func (MsgReduceCollateral) ValidateBasic

func (m MsgReduceCollateral) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgRemoveOperator

type MsgRemoveOperator struct {
	Address  sdk.AccAddress
	Proposer sdk.AccAddress
}

func NewMsgRemoveOperator

func NewMsgRemoveOperator(address sdk.AccAddress, proposer sdk.AccAddress) MsgRemoveOperator

NewMsgRemoveOperator returns the message for removing an operator.

func (MsgRemoveOperator) GetSignBytes

func (m MsgRemoveOperator) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgRemoveOperator) GetSigners

func (m MsgRemoveOperator) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgRemoveOperator) Route

func (MsgRemoveOperator) Route() string

Route returns the module name.

func (MsgRemoveOperator) Type

func (MsgRemoveOperator) Type() string

Type returns the action name.

func (MsgRemoveOperator) ValidateBasic

func (m MsgRemoveOperator) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgTaskResponse

type MsgTaskResponse struct {
	Contract string
	Function string
	Score    int64
	Operator sdk.AccAddress
}

MsgTaskResponse is the message for responding to a task.

func NewMsgTaskResponse

func NewMsgTaskResponse(contract, function string, score int64, operator sdk.AccAddress) MsgTaskResponse

NewMsgTaskResponse returns a new message for responding to a task.

func (MsgTaskResponse) GetSignBytes

func (m MsgTaskResponse) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgTaskResponse) GetSigners

func (m MsgTaskResponse) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgTaskResponse) Route

func (MsgTaskResponse) Route() string

Route returns the module name.

func (MsgTaskResponse) Type

func (MsgTaskResponse) Type() string

Type returns the action name.

func (MsgTaskResponse) ValidateBasic

func (m MsgTaskResponse) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type MsgWithdrawReward

type MsgWithdrawReward struct {
	Address sdk.AccAddress
}

func NewMsgWithdrawReward

func NewMsgWithdrawReward(address sdk.AccAddress) MsgWithdrawReward

NewMsgWithdrawReward returns the message for withdrawing reward.

func (MsgWithdrawReward) GetSignBytes

func (m MsgWithdrawReward) GetSignBytes() []byte

GetSignBytes encodes the message for signing.

func (MsgWithdrawReward) GetSigners

func (m MsgWithdrawReward) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required.

func (MsgWithdrawReward) Route

func (MsgWithdrawReward) Route() string

Route returns the module name.

func (MsgWithdrawReward) Type

func (MsgWithdrawReward) Type() string

Type returns the action name.

func (MsgWithdrawReward) ValidateBasic

func (m MsgWithdrawReward) ValidateBasic() error

ValidateBasic runs stateless checks on the message.

type Operator

type Operator struct {
	Address            sdk.AccAddress `json:"address"`
	Proposer           sdk.AccAddress `json:"proposer"`
	Collateral         sdk.Coins      `json:"collateral"`
	AccumulatedRewards sdk.Coins      `json:"accumulated_rewards"`
	Name               string         `json:"name"`
}

func NewOperator

func NewOperator(address sdk.AccAddress, proposer sdk.AccAddress, collateral sdk.Coins,
	accumulatedRewards sdk.Coins, name string) Operator

NewOperator returns an Operator object.

func (Operator) String

func (o Operator) String() string

String returns a human readable string representation of an operator.

type Operators

type Operators []Operator

func (Operators) String

func (operators Operators) String() (out string)

type ParamSubspace

type ParamSubspace interface {
	Get(ctx sdk.Context, key []byte, ptr interface{})
	Set(ctx sdk.Context, key []byte, param interface{})
	WithKeyTable(table subspace.KeyTable) subspace.Subspace
}

type QueryResponseParams

type QueryResponseParams struct {
	Contract string
	Function string
	Operator sdk.AccAddress
}

func NewQueryResponseParams

func NewQueryResponseParams(contract string, function string, operator sdk.AccAddress) QueryResponseParams

NewQueryResponseParams returns a QueryResponseParams.

type QueryTaskParams

type QueryTaskParams struct {
	Contract string
	Function string
}

func NewQueryTaskParams

func NewQueryTaskParams(contract string, function string) QueryTaskParams

NewQueryTaskParams returns a QueryTaskParams object.

type Response

type Response struct {
	Contract string         `json:"contract"`
	Function string         `json:"function"`
	Score    sdk.Int        `json:"score"`
	Operator sdk.AccAddress `json:"operator"`
}

Response defines the data structure of a response.

func NewResponse

func NewResponse(contract, function string, score sdk.Int, operator sdk.AccAddress) Response

NewResponse returns a new response.

type SupplyKeeper

type SupplyKeeper interface {
	GetModuleAddress(moduleName string) sdk.AccAddress
	SendCoinsFromAccountToModule(
		ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	SendCoinsFromModuleToAccount(
		ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
}

type Task

type Task struct {
	Contract      string         `json:"contract"`
	Function      string         `json:"function"`
	Bounty        sdk.Coins      `json:"bounty"`
	Description   string         `json:"string"`
	Expiration    time.Time      `json:"expiration"`
	Creator       sdk.AccAddress `json:"creator"`
	Responses     []Response     `json:"responses"`
	Result        sdk.Int        `json:"result"`
	ClosingBlock  int64          `json:"closing_block"`
	WaitingBlocks int64          `json:"waiting_blocks"`
	Status        TaskStatus     `json:"status"`
}

Task defines the data structure of a task.

func NewTask

func NewTask(
	contract string,
	function string,
	bounty sdk.Coins,
	description string,
	expiration time.Time,
	creator sdk.AccAddress,
	closingBlock int64,
	waitingBlocks int64,
) Task

NewTask returns a new task.

type TaskID

type TaskID struct {
	Contract string `json:"contract"`
	Function string `json:"function"`
}

TaskID defines the data structure of the ID of a task.

type TaskParams

type TaskParams struct {
	ExpirationDuration time.Duration `json:"task_expiration_duration"`
	AggregationWindow  int64         `json:"task_aggregation_window"`
	AggregationResult  sdk.Int       `json:"task_aggregation_result"`
	ThresholdScore     sdk.Int       `json:"task_threshold_score"`
	Epsilon1           sdk.Int       `json:"task_epsilon1"`
	Epsilon2           sdk.Int       `json:"task_epsilon2"`
}

func DefaultTaskParams

func DefaultTaskParams() TaskParams

DefaultTaskParams generates default set for TaskParams.

func NewTaskParams

func NewTaskParams(expirationDuration time.Duration, aggregationWindow int64, aggregationResult,
	thredholdScore, epsilon1, epsilon2 sdk.Int) TaskParams

NewTaskParams returns a TaskParams object.

type TaskStatus

type TaskStatus byte

TaskStatus defines the data type of the status of a task.

func (TaskStatus) String

func (t TaskStatus) String() string

type Withdraw

type Withdraw struct {
	Address  sdk.AccAddress `json:"address"`
	Amount   sdk.Coins      `json:"amount"`
	DueBlock int64          `json:"due_block"`
}

func NewWithdraw

func NewWithdraw(address sdk.AccAddress, amount sdk.Coins, dueBlock int64) Withdraw

NewWithdraw returns a Withdraw object.

func (Withdraw) String

func (w Withdraw) String() string

String returns a human readable string representation of a withdraw object.

type Withdraws

type Withdraws []Withdraw

func (Withdraws) String

func (withdraws Withdraws) String() (out string)

Jump to

Keyboard shortcuts

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