model

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrDelegationNotFound

func ErrDelegationNotFound() sdk.Error

ErrDelegationNotFound - error if delegation is not found in KVStore

func ErrFailedToMarshalDelegation

func ErrFailedToMarshalDelegation(err error) sdk.Error

ErrFailedToMarshalDelegation - error if marshal delegation failed

func ErrFailedToMarshalReferenceList

func ErrFailedToMarshalReferenceList(err error) sdk.Error

ErrFailedToMarshalReferenceList - error if marshal reference list failed

func ErrFailedToMarshalVote

func ErrFailedToMarshalVote(err error) sdk.Error

ErrFailedToMarshalVote - error if marshal vote failed

func ErrFailedToMarshalVoter

func ErrFailedToMarshalVoter(err error) sdk.Error

ErrFailedToMarshalVoter - error if marshal voter failed

func ErrFailedToUnmarshalDelegation

func ErrFailedToUnmarshalDelegation(err error) sdk.Error

ErrFailedToUnmarshalDelegation - error if unmarshal delegation failed

func ErrFailedToUnmarshalReferenceList

func ErrFailedToUnmarshalReferenceList(err error) sdk.Error

ErrFailedToUnmarshalReferenceList - error if unmarshal reference list failed

func ErrFailedToUnmarshalVote

func ErrFailedToUnmarshalVote(err error) sdk.Error

ErrFailedToUnmarshalVote - error if unmarshal vote failed

func ErrFailedToUnmarshalVoter

func ErrFailedToUnmarshalVoter(err error) sdk.Error

ErrFailedToUnmarshalVoter - error if unmarshal voter failed

func ErrReferenceListNotFound

func ErrReferenceListNotFound() sdk.Error

ErrReferenceListNotFound - error if reference list is not found in KVStore

func ErrVoteNotFound

func ErrVoteNotFound() sdk.Error

ErrVoteNotFound - error if vote is not found in KVStore

func ErrVoterNotFound

func ErrVoterNotFound() sdk.Error

ErrVoterNotFound - error if voter is not found in KVStore

func GetDelegationKey

func GetDelegationKey(me types.AccountKey, myDelegator types.AccountKey) []byte

GetDelegationKey - "delegation substore" + "me(voter)" + "my delegator"

func GetVoteKey

func GetVoteKey(proposalID types.ProposalKey, voter types.AccountKey) []byte

GetVoteKey - "vote substore" + "proposalID" + "voter"

func GetVoterKey

func GetVoterKey(me types.AccountKey) []byte

GetVoterKey - "voter substore" + "voter"

Types

type Delegation

type Delegation struct {
	Delegator types.AccountKey `json:"delegator"`
	Amount    types.Coin       `json:"amount"`
}

Delegation - normal user can delegate money to a voter to increase voter's voting power

type ReferenceList

type ReferenceList struct {
	AllValidators []types.AccountKey `json:"all_validators"`
}

ReferenceList - record validator to punish the validator who doesn't vote for proposal

type Vote

type Vote struct {
	Voter       types.AccountKey `json:"voter"`
	VotingPower types.Coin       `json:"voting_power"`
	Result      bool             `json:"result"`
}

Vote - a vote is created by a voter to a proposal

type VoteStorage

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

VoteStorage - vote storage

func NewVoteStorage

func NewVoteStorage(key sdk.StoreKey) VoteStorage

NewVoteStorage - new vote storage

func (VoteStorage) DeleteDelegation

func (vs VoteStorage) DeleteDelegation(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey) sdk.Error

DeleteDelegation - delete delegation from KVStore

func (VoteStorage) DeleteVote

func (vs VoteStorage) DeleteVote(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey) sdk.Error

DeleteVote - delete vote from KVStore

func (VoteStorage) DeleteVoter

func (vs VoteStorage) DeleteVoter(ctx sdk.Context, username types.AccountKey) sdk.Error

DeleteVoter - delete voter from KVStore

func (VoteStorage) DoesDelegationExist

func (vs VoteStorage) DoesDelegationExist(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey) bool

DoesDelegationExist - check if delegation exist in KVStore or not

func (VoteStorage) DoesVoteExist

func (vs VoteStorage) DoesVoteExist(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey) bool

DoesVoteExist - check if vote exist in KVStore or not

func (VoteStorage) DoesVoterExist

func (vs VoteStorage) DoesVoterExist(ctx sdk.Context, accKey types.AccountKey) bool

DoesVoterExist - check if voter exist in KVStore or not

func (VoteStorage) GetAllDelegators

func (vs VoteStorage) GetAllDelegators(ctx sdk.Context, voterName types.AccountKey) ([]types.AccountKey, sdk.Error)

GetAllDelegators - get all delegators of a voter from KVStore

func (VoteStorage) GetAllVotes

func (vs VoteStorage) GetAllVotes(ctx sdk.Context, proposalID types.ProposalKey) ([]Vote, sdk.Error)

GetAllVotes - get all votes of a proposal from KVStore

func (VoteStorage) GetDelegation

func (vs VoteStorage) GetDelegation(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey) (*Delegation, sdk.Error)

GetDelegation - get delegation from KVStore

func (VoteStorage) GetReferenceList

func (vs VoteStorage) GetReferenceList(ctx sdk.Context) (*ReferenceList, sdk.Error)

GetReferenceList - get reference list from KVStore

func (VoteStorage) GetVote

func (vs VoteStorage) GetVote(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey) (*Vote, sdk.Error)

GetVote - get vote from KVStore

func (VoteStorage) GetVoter

func (vs VoteStorage) GetVoter(ctx sdk.Context, accKey types.AccountKey) (*Voter, sdk.Error)

GetVoter - get voter from KVStore

func (VoteStorage) InitGenesis

func (vs VoteStorage) InitGenesis(ctx sdk.Context) sdk.Error

InitGenesis - initialize genesis

func (VoteStorage) SetDelegation

func (vs VoteStorage) SetDelegation(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey, delegation *Delegation) sdk.Error

SetDelegation - set delegation to KVStore

func (VoteStorage) SetReferenceList

func (vs VoteStorage) SetReferenceList(ctx sdk.Context, lst *ReferenceList) sdk.Error

SetReferenceList - set reference list to KVStore

func (VoteStorage) SetVote

func (vs VoteStorage) SetVote(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey, vote *Vote) sdk.Error

SetVote - set vote to KVStore

func (VoteStorage) SetVoter

func (vs VoteStorage) SetVoter(ctx sdk.Context, accKey types.AccountKey, voter *Voter) sdk.Error

SetVoter - set voter to KVStore

type Voter

type Voter struct {
	Username          types.AccountKey `json:"username"`
	LinoStake         types.Coin       `json:"lino_stake"`
	DelegatedPower    types.Coin       `json:"delegated_power"`
	DelegateToOthers  types.Coin       `json:"delegate_to_others"`
	LastPowerChangeAt int64            `json:"last_power_change_at"`
	Interest          types.Coin       `json:"interest"`
}

Voter - a voter in blockchain is account with voter deposit, who can vote for a proposal

Jump to

Keyboard shortcuts

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