types

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// module name
	ModuleName = "validator"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName

	AttributeKeyEthAddress = "eth_address"

	ActionInitiateWithdraw = "initate_withdraw"
)
View Source
const (
	TypeMsgSetTransactors           = "set_transactors"
	TypeMsgEditCandidateDescription = "edit_candidate_description"
	TypeMsgWithdrawReward           = "withdraw_reward"
	TypeMsgSignReward               = "sign_reward"
)
View Source
const (
	DefaultSyncerDuration   uint          = 10
	DefaultEpochLength      uint          = 5
	DefaultMaxValidatorDiff uint          = 10
	DefaultWithdrawWindow   time.Duration = time.Hour
)

validator params default values

View Source
const (
	QuerySyncer              = "syncer"
	QueryDelegator           = "delegator"
	QueryCandidate           = "candidate"
	QueryCandidates          = "candidates"
	QueryCandidateDelegators = "candidate-delegators"
	QueryReward              = "reward"
	QueryRewardEpoch         = "reward-epoch"
	QueryRewardStats         = "reward-stats"
	QueryParameters          = "parameters"
)
View Source
const RouterKey = ModuleName // this was defined in your key.go file

Variables

View Source
var (
	SyncerKey              = []byte{0x01} // key for syncer
	DelegatorKeyPrefix     = []byte{0x03} // Key prefix for delegator
	CandidateKeyPrefix     = []byte{0x04} // Key prefix for candidate
	RewardKeyPrefix        = []byte{0x05} // Key prefix for reward
	RewardEpochKey         = []byte{0x06} // Key for reward epoch
	PendingRewardKeyPrefix = []byte{0x07} // Key for pending reward
)
View Source
var (
	DefaultMiningReward = sdk.NewInt(10000000000000)
	DefaultPullerReward = sdk.NewInt(500000000000)
)
View Source
var (
	KeySyncerDuration   = []byte("SyncerDuration")
	KeyEpochLength      = []byte("EpochLength")
	KeyMaxValidatorDiff = []byte("KeyMaxValidatorDiff")
	KeyWithdrawWindow   = []byte("WithdrawWindow")
	KeyMiningReward     = []byte("MiningReward")
	KeyPullerReward     = []byte("PullerReward")
)

nolint - Keys for parameter access

View Source
var ModuleCdc = codec.New()

Functions

func GetCandidateKey

func GetCandidateKey(candidateAddr string) []byte

get candidate key from candidateAddr

func GetDelegatorKey

func GetDelegatorKey(candidateAddr, delegatorAddr string) []byte

get delegator key from candidate address and delegator address

func GetDelegatorsKey

func GetDelegatorsKey(candidateAddr string) []byte

get delegators key from candidate address

func GetPendingRewardKey added in v0.2.4

func GetPendingRewardKey(candidateAddr string) []byte

func GetRewardKey

func GetRewardKey(ethAddr string) []byte

get reward key from ethAddr

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec

Types

type Candidate

type Candidate struct {
	EthAddress     string              `json:"eth_address"`
	ValAccount     sdk.AccAddress      `json:"val_account"`
	Transactors    []sdk.AccAddress    `json:"transactors"`
	StakingPool    sdk.Int             `json:"staking_pool"`
	CommissionRate sdk.Dec             `json:"commission_rate"`
	RequestCount   sdk.Int             `json:"request_count"`
	Description    staking.Description `json:"description"`
}

valAccount will be used for running validator node, and transactors will be used for running gateway

func NewCandidate

func NewCandidate(ethAddress string, acctAddress sdk.AccAddress) Candidate

func (Candidate) String

func (c Candidate) String() string

implement fmt.Stringer

type Delegator

type Delegator struct {
	CandidateAddr  string  `json:"candidate_addr"`
	DelegatorAddr  string  `json:"delegator_addr"`
	DelegatedStake sdk.Int `json:"delegated_stake"`
}

func NewDelegator

func NewDelegator(candidateAddr, delegatorAddr string) Delegator

func (Delegator) String

func (d Delegator) String() string

implement fmt.Stringer

type MsgEditCandidateDescription added in v0.2.3

type MsgEditCandidateDescription struct {
	EthAddress  string              `json:"eth_address"`
	Description staking.Description `json:"description"`
	Sender      sdk.AccAddress      `json:"sender"`
}

func NewMsgEditCandidateDescription added in v0.2.3

func NewMsgEditCandidateDescription(ethAddress string, description staking.Description, sender sdk.AccAddress) MsgEditCandidateDescription

NewMsgEditCandidateDescription is a constructor function for MsgEditCandidateDescription

func (MsgEditCandidateDescription) GetSignBytes added in v0.2.3

func (msg MsgEditCandidateDescription) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgEditCandidateDescription) GetSigners added in v0.2.3

func (msg MsgEditCandidateDescription) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgEditCandidateDescription) Route added in v0.2.3

func (msg MsgEditCandidateDescription) Route() string

Route should return the name of the module

func (MsgEditCandidateDescription) Type added in v0.2.3

Type should return the action

func (MsgEditCandidateDescription) ValidateBasic added in v0.2.3

func (msg MsgEditCandidateDescription) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgSetTransactors added in v0.2.0

type MsgSetTransactors struct {
	Transactors []sdk.AccAddress `json:"transactors"`
	Sender      sdk.AccAddress   `json:"sender"`
}

func NewMsgSetTransactors added in v0.2.0

func NewMsgSetTransactors(transactors []sdk.AccAddress, sender sdk.AccAddress) MsgSetTransactors

NewMsgSetTransactors is a constructor function for MsgSetTransactors

func (MsgSetTransactors) GetSignBytes added in v0.2.0

func (msg MsgSetTransactors) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgSetTransactors) GetSigners added in v0.2.0

func (msg MsgSetTransactors) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgSetTransactors) Route added in v0.2.0

func (msg MsgSetTransactors) Route() string

Route should return the name of the module

func (MsgSetTransactors) Type added in v0.2.0

func (msg MsgSetTransactors) Type() string

Type should return the action

func (MsgSetTransactors) ValidateBasic added in v0.2.0

func (msg MsgSetTransactors) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgSignReward

type MsgSignReward struct {
	EthAddress string         `json:"eth_address"`
	Sig        []byte         `json:"sig"`
	Sender     sdk.AccAddress `json:"sender"`
}

MsgSignReward defines a SyncValidator message

func NewMsgSignReward

func NewMsgSignReward(ethAddress string, sig []byte, sender sdk.AccAddress) MsgSignReward

func (MsgSignReward) GetSignBytes

func (msg MsgSignReward) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgSignReward) GetSigners

func (msg MsgSignReward) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgSignReward) Route

func (msg MsgSignReward) Route() string

Route should return the name of the module

func (MsgSignReward) Type

func (msg MsgSignReward) Type() string

Type should return the action

func (MsgSignReward) ValidateBasic

func (msg MsgSignReward) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgWithdrawReward

type MsgWithdrawReward struct {
	EthAddress string         `json:"eth_address"`
	Sender     sdk.AccAddress `json:"sender"`
}

MsgWithdrawReward defines a SyncValidator message

func NewMsgWithdrawReward

func NewMsgWithdrawReward(ethAddress string, sender sdk.AccAddress) MsgWithdrawReward

func (MsgWithdrawReward) GetSignBytes

func (msg MsgWithdrawReward) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgWithdrawReward) GetSigners

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

GetSigners defines whose signature is required

func (MsgWithdrawReward) Route

func (msg MsgWithdrawReward) Route() string

Route should return the name of the module

func (MsgWithdrawReward) Type

func (msg MsgWithdrawReward) Type() string

Type should return the action

func (MsgWithdrawReward) ValidateBasic

func (msg MsgWithdrawReward) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type Params

type Params struct {
	SyncerDuration   uint          `json:"syncer_duration" yaml:"syncer_duration"`
	EpochLength      uint          `json:"epoch_length" yaml:"epoch_length"`
	MaxValidatorDiff uint          `json:"max_validator_diff" yaml:"max_validator_diff"`
	WithdrawWindow   time.Duration `json:"withdraw_window" yaml:"withdraw_window"`
	MiningReward     sdk.Int       `json:"mining_reward" yaml:"mining_reward"`
	PullerReward     sdk.Int       `json:"puller_reward" yaml:"puller_reward"`
}

func DefaultParams

func DefaultParams() Params

DefaultParams returns a default set of parameters.

func MustUnmarshalParams

func MustUnmarshalParams(cdc *codec.Codec, value []byte) Params

unmarshal the current validator params value from store key or panic

func NewParams

func NewParams(
	syncerDuration, epochLength, maxValidatorDiff uint,
	withdrawWindow time.Duration,
	miningReward, pullerReward sdk.Int) Params

NewParams creates a new Params instance

func UnmarshalParams

func UnmarshalParams(cdc *codec.Codec, value []byte) (params Params, err error)

unmarshal the current validator params value from store key

func (Params) Equal

func (p Params) Equal(p2 Params) bool

Equal returns a boolean determining if two Param types are identical.

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

Implements params.ParamSet

func (Params) String

func (p Params) String() string

String returns a human readable string representation of the parameters.

func (Params) Validate

func (p Params) Validate() error

validate a set of params

type PendingReward added in v0.2.4

type PendingReward struct {
	CandidateAddr string  `json:"candidate_addr"`
	MiningReward  sdk.Int `json:"mining_reward"`
	ServiceReward sdk.Int `json:"service_reward"`
}

func NewPendingReward added in v0.2.4

func NewPendingReward(ethAddress string) PendingReward

func (PendingReward) IsZero added in v0.2.4

func (pr PendingReward) IsZero() bool

type QueryCandidateParams

type QueryCandidateParams struct {
	CandidateAddress string
}

func NewQueryCandidateParams

func NewQueryCandidateParams(candidateAddress string) QueryCandidateParams

type QueryDelegatorParams

type QueryDelegatorParams struct {
	CandidateAddress string
	DelegatorAddress string
}

func NewQueryDelegatorParams

func NewQueryDelegatorParams(candidateAddress, delegatorAddress string) QueryDelegatorParams

type QueryRewardParams

type QueryRewardParams struct {
	EthAddress string
}

func NewQueryRewardParams

func NewQueryRewardParams(ethAddress string) QueryRewardParams

type Reward

type Reward struct {
	Receiver         string       `json:"receiver"`
	MiningReward     sdk.Int      `json:"mining_reward"`
	ServiceReward    sdk.Int      `json:"service_reward"`
	RewardProtoBytes []byte       `json:"reward_proto_bytes"` // proto msg for reward snapshot from latest intendWithdraw
	LastWithdrawTime time.Time    `json:"last_withdraw_time"` // last time the user triggers withdraw
	Sigs             []common.Sig `json:"sigs"`
}

func NewReward

func NewReward(receiver string) Reward

func (*Reward) AddSig

func (r *Reward) AddSig(sig []byte, expectedSigner string) error

Add signature to reward sigs

func (Reward) GetRewardRequest

func (r Reward) GetRewardRequest() []byte

Generate rewardRequest msg

func (*Reward) InitateWithdraw

func (r *Reward) InitateWithdraw(now time.Time)

Initiate the withdraw process

func (Reward) String

func (r Reward) String() string

implement fmt.Stringer

type RewardEpoch added in v0.2.4

type RewardEpoch struct {
	StartHeight   int64   `json:"start_height"`
	MiningReward  sdk.Int `json:"mining_reward"`
	ServiceReward sdk.Int `json:"service_reward"`
}

func NewRewardEpoch added in v0.2.4

func NewRewardEpoch(height int64) RewardEpoch

type RewardStats added in v0.2.5

type RewardStats struct {
	TotalMiningReward  sdk.Int `json:"total_mining_reward"`
	TotalServiceReward sdk.Int `json:"total_service_reward"`
	NumReceiver        uint    `json:"num_receiver"`
	NumWithdrawer      uint    `json:"num_withdrawer"`
	MaxReward          sdk.Int `json:"max_reward"`
	MaxRewardReceiver  string  `json:"max_reward_receiver"`
}

func NewRewardStats added in v0.2.5

func NewRewardStats() RewardStats

type Syncer added in v0.2.3

type Syncer struct {
	ValidatorIdx  uint           `json:"validator_idx"`
	ValidatorAddr sdk.AccAddress `json:"validator_addr"`
}

func NewSyncer added in v0.2.3

func NewSyncer(validatorIdx uint, validatorAddr sdk.AccAddress) Syncer

func (Syncer) String added in v0.2.3

func (r Syncer) String() string

implement fmt.Stringer

Jump to

Keyboard shortcuts

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