model

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: 6 Imported by: 4

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 DelegationRow added in v0.2.0

type DelegationRow struct {
	Voter      types.AccountKey `json:"username"`
	Delegator  types.AccountKey `json:"delegator"`
	Delegation Delegation       `json:"delegation"`
}

DelegationRow - pk: (voter, delegator)

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 ReferenceListTable added in v0.2.0

type ReferenceListTable struct {
	List ReferenceList `json:"list"`
}

ReferenceListTable - no pk

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) Export added in v0.2.0

func (vs VoteStorage) Export(ctx sdk.Context) *VoterTables

Export - Export voter state

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) Import added in v0.2.0

func (vs VoteStorage) Import(ctx sdk.Context, ir *VoterTablesIR)

Import - Import voter state

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"`
	Duty              votetypes.VoterDuty `json:"duty"`
	FrozenAmount      types.Coin          `json:"frozen_amount"`
}

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

type VoterRow added in v0.2.0

type VoterRow struct {
	Username types.AccountKey `json:"username"`
	Voter    Voter            `json:"voter"`
}

VoterRow - pk: username

type VoterTables added in v0.2.0

type VoterTables struct {
	Voters        []VoterRow         `json:"voters"`
	Delegations   []DelegationRow    `json:"delegations"`
	ReferenceList ReferenceListTable `json:"reference_list"`
}

VoterTables - state of voter

func (VoterTables) ToIR added in v0.2.0

func (v VoterTables) ToIR() VoterTablesIR

ToIR - same

type VoterTablesIR added in v0.2.0

type VoterTablesIR = VoterTables

VoterTablesIR - same

Jump to

Keyboard shortcuts

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