Documentation
¶
Index ¶
- func ErrDelegationNotFound() sdk.Error
- func ErrFailedToMarshalDelegation(err error) sdk.Error
- func ErrFailedToMarshalReferenceList(err error) sdk.Error
- func ErrFailedToMarshalVote(err error) sdk.Error
- func ErrFailedToMarshalVoter(err error) sdk.Error
- func ErrFailedToUnmarshalDelegation(err error) sdk.Error
- func ErrFailedToUnmarshalReferenceList(err error) sdk.Error
- func ErrFailedToUnmarshalVote(err error) sdk.Error
- func ErrFailedToUnmarshalVoter(err error) sdk.Error
- func ErrReferenceListNotFound() sdk.Error
- func ErrVoteNotFound() sdk.Error
- func ErrVoterNotFound() sdk.Error
- func GetDelegationKey(me types.AccountKey, myDelegator types.AccountKey) []byte
- func GetVoteKey(proposalID types.ProposalKey, voter types.AccountKey) []byte
- func GetVoterKey(me types.AccountKey) []byte
- type Delegation
- type ReferenceList
- type Vote
- type VoteStorage
- func (vs VoteStorage) DeleteDelegation(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey) sdk.Error
- func (vs VoteStorage) DeleteVote(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey) sdk.Error
- func (vs VoteStorage) DeleteVoter(ctx sdk.Context, username types.AccountKey) sdk.Error
- func (vs VoteStorage) DoesDelegationExist(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey) bool
- func (vs VoteStorage) DoesVoteExist(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey) bool
- func (vs VoteStorage) DoesVoterExist(ctx sdk.Context, accKey types.AccountKey) bool
- func (vs VoteStorage) GetAllDelegators(ctx sdk.Context, voterName types.AccountKey) ([]types.AccountKey, sdk.Error)
- func (vs VoteStorage) GetAllVotes(ctx sdk.Context, proposalID types.ProposalKey) ([]Vote, sdk.Error)
- func (vs VoteStorage) GetDelegation(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey) (*Delegation, sdk.Error)
- func (vs VoteStorage) GetReferenceList(ctx sdk.Context) (*ReferenceList, sdk.Error)
- func (vs VoteStorage) GetVote(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey) (*Vote, sdk.Error)
- func (vs VoteStorage) GetVoter(ctx sdk.Context, accKey types.AccountKey) (*Voter, sdk.Error)
- func (vs VoteStorage) InitGenesis(ctx sdk.Context) sdk.Error
- func (vs VoteStorage) SetDelegation(ctx sdk.Context, voter types.AccountKey, delegator types.AccountKey, ...) sdk.Error
- func (vs VoteStorage) SetReferenceList(ctx sdk.Context, lst *ReferenceList) sdk.Error
- func (vs VoteStorage) SetVote(ctx sdk.Context, proposalID types.ProposalKey, voter types.AccountKey, ...) sdk.Error
- func (vs VoteStorage) SetVoter(ctx sdk.Context, accKey types.AccountKey, voter *Voter) sdk.Error
- type Voter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrDelegationNotFound ¶
ErrDelegationNotFound - error if delegation is not found in KVStore
func ErrFailedToMarshalDelegation ¶
ErrFailedToMarshalDelegation - error if marshal delegation failed
func ErrFailedToMarshalReferenceList ¶
ErrFailedToMarshalReferenceList - error if marshal reference list failed
func ErrFailedToMarshalVote ¶
ErrFailedToMarshalVote - error if marshal vote failed
func ErrFailedToMarshalVoter ¶
ErrFailedToMarshalVoter - error if marshal voter failed
func ErrFailedToUnmarshalDelegation ¶
ErrFailedToUnmarshalDelegation - error if unmarshal delegation failed
func ErrFailedToUnmarshalReferenceList ¶
ErrFailedToUnmarshalReferenceList - error if unmarshal reference list failed
func ErrFailedToUnmarshalVote ¶
ErrFailedToUnmarshalVote - error if unmarshal vote failed
func ErrFailedToUnmarshalVoter ¶
ErrFailedToUnmarshalVoter - error if unmarshal voter failed
func ErrReferenceListNotFound ¶
ErrReferenceListNotFound - error if reference list is not found in KVStore
func ErrVoteNotFound ¶
ErrVoteNotFound - error if vote is not found in KVStore
func ErrVoterNotFound ¶
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