vote

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: Apache-2.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// ModuleKey is the name of the module
	ModuleName = "vote"

	// RouterKey is the message route for gov
	RouterKey = ModuleName

	// QuerierRoute is the querier route for gov
	QuerierRoute = ModuleName

	QueryDelegation    = "delegation"
	QueryVoter         = "voter"
	QueryVote          = "vote"
	QueryReferenceList = "refList"
	QueryDelegatee     = "delegatee"
)

Variables

This section is empty.

Functions

func AddStake added in v0.1.1

func AddStake(
	ctx sdk.Context, username types.AccountKey, stake types.Coin, vm VoteManager,
	gm *global.GlobalManager, am acc.AccountKeeper) sdk.Error

func ErrAccountNotFound

func ErrAccountNotFound() sdk.Error

ErrAccountNotFound - error if account is not found

func ErrIllegalWithdraw

func ErrIllegalWithdraw() sdk.Error

ErrIllegalWithdraw - error if withdraw is illegal

func ErrInsufficientDeposit

func ErrInsufficientDeposit() sdk.Error

ErrInsufficientDeposit - error if voter deposit is insufficient

func ErrInsufficientStake added in v0.3.0

func ErrInsufficientStake() sdk.Error

ErrInsufficientStake

func ErrInvalidCoin

func ErrInvalidCoin() sdk.Error

ErrInvalidCoin - error if coin is invalid

func ErrInvalidUsername

func ErrInvalidUsername() sdk.Error

ErrInvalidUsername - error if username is invalid

func ErrNotAVoterOrHasDuty added in v0.3.0

func ErrNotAVoterOrHasDuty() sdk.Error

ErrNotAVoterOrHasDuty

func ErrQueryFailed added in v0.2.0

func ErrQueryFailed() sdk.Error

ErrQueryFailed - error when query vote store failed

func ErrValidatorCannotRevoke

func ErrValidatorCannotRevoke() sdk.Error

ErrValidatorCannotRevoke - error if voter is validator

func ErrVoteAlreadyExist

func ErrVoteAlreadyExist() sdk.Error

ErrVoteAlreadyExist - error if user already vote for a proposal

func ErrVoterNotFound added in v0.1.1

func ErrVoterNotFound() sdk.Error

ErrVoteNotFound - error if voter is not found

func MinusStake added in v0.1.1

func MinusStake(
	ctx sdk.Context, username types.AccountKey, stake types.Coin, vm VoteManager,
	gm *global.GlobalManager, am acc.AccountKeeper) sdk.Error

func NewHandler

NewHandler - Handle all "vote" type messages.

func NewQuerier added in v0.2.0

func NewQuerier(vm VoteManager) sdk.Querier

creates a querier for vote REST endpoints

func RegisterWire

func RegisterWire(cdc *wire.Codec)

Register concrete types on wire codec

Types

type ClaimInterestMsg added in v0.1.1

type ClaimInterestMsg struct {
	Username types.AccountKey `json:"username"`
}

ClaimInterestMsg - claim interest generated from lino power

func NewClaimInterestMsg added in v0.1.1

func NewClaimInterestMsg(username string) ClaimInterestMsg

NewClaimInterestMsg - return a ClaimInterestMsg

func (ClaimInterestMsg) GetConsumeAmount added in v0.1.1

func (msg ClaimInterestMsg) GetConsumeAmount() types.Coin

GetConsumeAmount - implements types.Msg

func (ClaimInterestMsg) GetPermission added in v0.1.1

func (msg ClaimInterestMsg) GetPermission() types.Permission

GetPermission - implements types.Msg

func (ClaimInterestMsg) GetSignBytes added in v0.1.1

func (msg ClaimInterestMsg) GetSignBytes() []byte

GetSignBytes - implements sdk.Msg

func (ClaimInterestMsg) GetSigners added in v0.1.1

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

GetSigners - implements sdk.Msg

func (ClaimInterestMsg) Route added in v0.2.0

func (msg ClaimInterestMsg) Route() string

Route - implements sdk.Msg

func (ClaimInterestMsg) String added in v0.1.1

func (msg ClaimInterestMsg) String() string

func (ClaimInterestMsg) Type added in v0.1.1

func (msg ClaimInterestMsg) Type() string

Type - implements sdk.Msg

func (ClaimInterestMsg) ValidateBasic added in v0.1.1

func (msg ClaimInterestMsg) ValidateBasic() sdk.Error

ValidateBasic - implements sdk.Msg

type DelegateMsg

type DelegateMsg struct {
	Delegator types.AccountKey `json:"delegator"`
	Voter     types.AccountKey `json:"voter"`
	Amount    types.LNO        `json:"amount"`
}

DelegateMsg - delegator delegate money to a voter

func NewDelegateMsg

func NewDelegateMsg(delegator string, voter string, amount types.LNO) DelegateMsg

NewDelegateMsg - return DelegateMsg

func (DelegateMsg) GetConsumeAmount

func (msg DelegateMsg) GetConsumeAmount() types.Coin

GetConsumeAmount - implement types.Msg

func (DelegateMsg) GetPermission

func (msg DelegateMsg) GetPermission() types.Permission

GetPermission - implements types.Msg

func (DelegateMsg) GetSignBytes

func (msg DelegateMsg) GetSignBytes() []byte

GetSignBytes - implements sdk.Msg

func (DelegateMsg) GetSigners

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

GetSigners - implements sdk.Msg

func (DelegateMsg) Route added in v0.2.0

func (msg DelegateMsg) Route() string

Route - implements sdk.Msg

func (DelegateMsg) String

func (msg DelegateMsg) String() string

func (DelegateMsg) Type

func (msg DelegateMsg) Type() string

Type - implements sdk.Msg

func (DelegateMsg) ValidateBasic

func (msg DelegateMsg) ValidateBasic() sdk.Error

ValidateBasic - implements sdk.Msg

type DelegatorWithdrawMsg

type DelegatorWithdrawMsg struct {
	Delegator types.AccountKey `json:"delegator"`
	Voter     types.AccountKey `json:"voter"`
	Amount    types.LNO        `json:"amount"`
}

DelegatorWithdrawMsg - delegator withdraw delegation from a voter

func NewDelegatorWithdrawMsg

func NewDelegatorWithdrawMsg(delegator string, voter string, amount types.LNO) DelegatorWithdrawMsg

NewDelegatorWithdrawMsg - return NewDelegatorWithdrawMsg

func (DelegatorWithdrawMsg) GetConsumeAmount

func (msg DelegatorWithdrawMsg) GetConsumeAmount() types.Coin

GetConsumeAmount - implement types.Msg

func (DelegatorWithdrawMsg) GetPermission

func (msg DelegatorWithdrawMsg) GetPermission() types.Permission

GetPermission - implements types.Msg

func (DelegatorWithdrawMsg) GetSignBytes

func (msg DelegatorWithdrawMsg) GetSignBytes() []byte

GetSignBytes - implements sdk.Msg

func (DelegatorWithdrawMsg) GetSigners

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

GetSigners - implements sdk.Msg

func (DelegatorWithdrawMsg) Route added in v0.2.0

func (msg DelegatorWithdrawMsg) Route() string

Route - implements sdk.Msg

func (DelegatorWithdrawMsg) String

func (msg DelegatorWithdrawMsg) String() string

func (DelegatorWithdrawMsg) Type

func (msg DelegatorWithdrawMsg) Type() string

Type - implements sdk.Msg

func (DelegatorWithdrawMsg) ValidateBasic

func (msg DelegatorWithdrawMsg) ValidateBasic() sdk.Error

ValidateBasic - implements sdk.Msg

type StakeInMsg added in v0.1.1

type StakeInMsg struct {
	Username types.AccountKey `json:"username"`
	Deposit  types.LNO        `json:"deposit"`
}

StakeInMsg - voter deposit

func NewStakeInMsg added in v0.1.1

func NewStakeInMsg(username string, deposit types.LNO) StakeInMsg

NewStakeInMsg - return a StakeInMsg

func (StakeInMsg) GetConsumeAmount added in v0.1.1

func (msg StakeInMsg) GetConsumeAmount() types.Coin

GetConsumeAmount - implement types.Msg

func (StakeInMsg) GetPermission added in v0.1.1

func (msg StakeInMsg) GetPermission() types.Permission

GetPermission - implements types.Msg

func (StakeInMsg) GetSignBytes added in v0.1.1

func (msg StakeInMsg) GetSignBytes() []byte

GetSignBytes - implements sdk.Msg

func (StakeInMsg) GetSigners added in v0.1.1

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

GetSigners - implements sdk.Msg

func (StakeInMsg) Route added in v0.2.0

func (msg StakeInMsg) Route() string

Route - implements sdk.Msg

func (StakeInMsg) String added in v0.1.1

func (msg StakeInMsg) String() string

func (StakeInMsg) Type added in v0.1.1

func (msg StakeInMsg) Type() string

Type - implements sdk.Msg

func (StakeInMsg) ValidateBasic added in v0.1.1

func (msg StakeInMsg) ValidateBasic() sdk.Error

ValidateBasic - implements sdk.Msg

type StakeOutMsg added in v0.1.1

type StakeOutMsg struct {
	Username types.AccountKey `json:"username"`
	Amount   types.LNO        `json:"amount"`
}

StakeOutMsg - voter withdraw

func NewStakeOutMsg added in v0.1.1

func NewStakeOutMsg(username string, amount types.LNO) StakeOutMsg

NewStakeOutMsg - return StakeOutMsg

func (StakeOutMsg) GetConsumeAmount added in v0.1.1

func (msg StakeOutMsg) GetConsumeAmount() types.Coin

GetConsumeAmount - implement types.Msg

func (StakeOutMsg) GetPermission added in v0.1.1

func (msg StakeOutMsg) GetPermission() types.Permission

GetPermission - implements types.Msg

func (StakeOutMsg) GetSignBytes added in v0.1.1

func (msg StakeOutMsg) GetSignBytes() []byte

GetSignBytes - implements sdk.Msg

func (StakeOutMsg) GetSigners added in v0.1.1

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

GetSigners - implements sdk.Msg

func (StakeOutMsg) Route added in v0.2.0

func (msg StakeOutMsg) Route() string

Route - implements sdk.Msg

func (StakeOutMsg) String added in v0.1.1

func (msg StakeOutMsg) String() string

func (StakeOutMsg) Type added in v0.1.1

func (msg StakeOutMsg) Type() string

Type - implements sdk.Msg

func (StakeOutMsg) ValidateBasic added in v0.1.1

func (msg StakeOutMsg) ValidateBasic() sdk.Error

ValidateBasic - implements sdk.Msg

type VoteKeeper added in v0.3.0

type VoteKeeper interface {
	DoesVoterExist(ctx sdk.Context, accKey linotypes.AccountKey) bool
	GetVoterDuty(ctx sdk.Context, accKey linotypes.AccountKey) (types.VoterDuty, sdk.Error)
	GetLinoStake(ctx sdk.Context, accKey linotypes.AccountKey) (linotypes.Coin, sdk.Error)
	AssignDuty(ctx sdk.Context, accKey linotypes.AccountKey, duty types.VoterDuty, frozenAmount linotypes.Coin) sdk.Error
}

type VoteManager

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

VoteManager - vote manager

func NewVoteManager

func NewVoteManager(key sdk.StoreKey, holder param.ParamHolder) VoteManager

func (VoteManager) AddDelegation

func (vm VoteManager) AddDelegation(ctx sdk.Context, voterName linotypes.AccountKey, delegatorName linotypes.AccountKey, coin linotypes.Coin) sdk.Error

AddDelegation - add delegation

func (VoteManager) AddInterest added in v0.1.1

func (vm VoteManager) AddInterest(
	ctx sdk.Context, username linotypes.AccountKey, interest linotypes.Coin) sdk.Error

AddInterest - add interst

func (VoteManager) AddLinoStake added in v0.1.1

func (vm VoteManager) AddLinoStake(ctx sdk.Context, username linotypes.AccountKey, coin linotypes.Coin) sdk.Error

AddLinoStake - add lino power

func (VoteManager) AddVote

func (vm VoteManager) AddVote(ctx sdk.Context, proposalID linotypes.ProposalKey, voter linotypes.AccountKey, res bool) sdk.Error

AddVote - voter vote for a proposal

func (VoteManager) AddVoter

func (vm VoteManager) AddVoter(ctx sdk.Context, username linotypes.AccountKey, coin linotypes.Coin) sdk.Error

AddVoter - add voter

func (VoteManager) AssignDuty added in v0.3.0

func (vm VoteManager) AssignDuty(ctx sdk.Context, user linotypes.AccountKey, duty types.VoterDuty, frozenAmount linotypes.Coin) sdk.Error

AssignDuty froze some amount of stake and assign a duty to user.

func (VoteManager) CanBecomeValidator

func (vm VoteManager) CanBecomeValidator(ctx sdk.Context, username linotypes.AccountKey) bool

CanBecomeValidator - check if vote deposit meet requirement or not

func (VoteManager) ClaimInterest added in v0.1.1

func (vm VoteManager) ClaimInterest(
	ctx sdk.Context, username linotypes.AccountKey) (linotypes.Coin, sdk.Error)

ClaimInterest - add lino power interst to user balance

func (VoteManager) DelegatorWithdraw

func (vm VoteManager) DelegatorWithdraw(
	ctx sdk.Context, voterName linotypes.AccountKey, delegatorName linotypes.AccountKey, coin linotypes.Coin) sdk.Error

DelegatorWithdraw - withdraw delegation

func (VoteManager) DoesDelegationExist

func (vm VoteManager) DoesDelegationExist(ctx sdk.Context, voter linotypes.AccountKey, delegator linotypes.AccountKey) bool

DoesVoterExist - check if delegation exist or not

func (VoteManager) DoesVoteExist

func (vm VoteManager) DoesVoteExist(ctx sdk.Context, proposalID linotypes.ProposalKey, accKey linotypes.AccountKey) bool

DoesVoterExist - check if vote exist or not

func (VoteManager) DoesVoterExist

func (vm VoteManager) DoesVoterExist(ctx sdk.Context, accKey linotypes.AccountKey) bool

DoesVoterExist - check if voter exist or not

func (VoteManager) Export added in v0.2.0

func (vm VoteManager) Export(ctx sdk.Context) *model.VoterTables

Export storage state.

func (VoteManager) GetAllDelegators

func (vm VoteManager) GetAllDelegators(ctx sdk.Context, voterName linotypes.AccountKey) ([]linotypes.AccountKey, sdk.Error)

GetAllDelegators - get all delegators of a voter

func (VoteManager) GetLinoStake added in v0.1.1

func (vm VoteManager) GetLinoStake(ctx sdk.Context, accKey linotypes.AccountKey) (linotypes.Coin, sdk.Error)

GetLinoStake - get lino stake

func (VoteManager) GetLinoStakeLastChangedAt added in v0.1.1

func (vm VoteManager) GetLinoStakeLastChangedAt(ctx sdk.Context, accKey linotypes.AccountKey) (int64, sdk.Error)

GetLinoStakeLastChangedAt - get linoStake last changed time

func (VoteManager) GetPenaltyList

func (vm VoteManager) GetPenaltyList(
	ctx sdk.Context, proposalID linotypes.ProposalKey, proposalType linotypes.ProposalType,
	oncallValidators []linotypes.AccountKey) (linotypes.PenaltyList, sdk.Error)

GetPenaltyList - get penalty list if voter is also validator doesn't vote

func (VoteManager) GetValidatorReferenceList

func (vm VoteManager) GetValidatorReferenceList(ctx sdk.Context) (*model.ReferenceList, sdk.Error)

GetValidatorReferenceList - get all delegatee

func (VoteManager) GetVote

func (vm VoteManager) GetVote(ctx sdk.Context, proposalID linotypes.ProposalKey, voter linotypes.AccountKey) (*model.Vote, sdk.Error)

GetVote - get vote detail based on voter and proposal ID

func (VoteManager) GetVoterDuty added in v0.3.0

func (vm VoteManager) GetVoterDuty(ctx sdk.Context, accKey linotypes.AccountKey) (types.VoterDuty, sdk.Error)

func (VoteManager) GetVotingPower

func (vm VoteManager) GetVotingPower(ctx sdk.Context, voterName linotypes.AccountKey) (linotypes.Coin, sdk.Error)

GetVotingPower - get voter voting power

func (VoteManager) Import added in v0.2.0

func (vm VoteManager) Import(ctx sdk.Context, voter *model.VoterTablesIR)

Import storage state.

func (VoteManager) InitGenesis

func (vm VoteManager) InitGenesis(ctx sdk.Context) error

InitGenesis - initialize KV Store

func (VoteManager) IsInValidatorList

func (vm VoteManager) IsInValidatorList(ctx sdk.Context, username linotypes.AccountKey) bool

DoesVoterExist - check if a voter is validator or not

func (VoteManager) IsLegalDelegatorWithdraw

func (vm VoteManager) IsLegalDelegatorWithdraw(
	ctx sdk.Context, voterName linotypes.AccountKey, delegatorName linotypes.AccountKey, coin linotypes.Coin) bool

IsLegalDelegatorWithdraw - check if delegator withdraw is valid or not

func (VoteManager) IsLegalVoterWithdraw

func (vm VoteManager) IsLegalVoterWithdraw(
	ctx sdk.Context, username linotypes.AccountKey, coin linotypes.Coin) bool

IsLegalVoterWithdraw - check withdraw voter is not validator

func (VoteManager) MinusLinoStake added in v0.1.1

func (vm VoteManager) MinusLinoStake(ctx sdk.Context, username linotypes.AccountKey, coin linotypes.Coin) sdk.Error

MinusLinoStake - this method won't check if it is a legal withdraw, caller should check by itself

func (VoteManager) SetLinoStakeLastChangedAt added in v0.1.1

func (vm VoteManager) SetLinoStakeLastChangedAt(ctx sdk.Context, accKey linotypes.AccountKey, lastChangedAt int64) sdk.Error

SetLinoStakeLastChangedAt - set linoStake last changed time

func (VoteManager) SetValidatorReferenceList

func (vm VoteManager) SetValidatorReferenceList(ctx sdk.Context, lst *model.ReferenceList) sdk.Error

SetValidatorReferenceList - set validator reference list

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

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