Documentation ¶
Index ¶
- Constants
- Variables
- func KeyTable() paramtypes.KeyTable
- func NewPollMetaData(key exported.PollKey, threshold utils.Threshold, voters []exported.Voter, ...) exported.PollMetadata
- func RegisterInterfaces(cdctypes.InterfaceRegistry)
- func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
- type GenesisState
- func (*GenesisState) Descriptor() ([]byte, []int)
- func (m *GenesisState) Marshal() (dAtA []byte, err error)
- func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)
- func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GenesisState) ProtoMessage()
- func (m *GenesisState) Reset()
- func (m *GenesisState) Size() (n int)
- func (m *GenesisState) String() string
- func (m *GenesisState) Unmarshal(dAtA []byte) error
- func (m GenesisState) Validate() error
- func (m *GenesisState) XXX_DiscardUnknown()
- func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GenesisState) XXX_Merge(src proto.Message)
- func (m *GenesisState) XXX_Size() int
- func (m *GenesisState) XXX_Unmarshal(b []byte) error
- type Params
- func (*Params) Descriptor() ([]byte, []int)
- func (m *Params) Marshal() (dAtA []byte, err error)
- func (m *Params) MarshalTo(dAtA []byte) (int, error)
- func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (m *Params) ParamSetPairs() paramtypes.ParamSetPairs
- func (*Params) ProtoMessage()
- func (m *Params) Reset()
- func (m *Params) Size() (n int)
- func (m *Params) String() string
- func (m *Params) Unmarshal(dAtA []byte) error
- func (m Params) Validate() error
- func (m *Params) XXX_DiscardUnknown()
- func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Params) XXX_Merge(src proto.Message)
- func (m *Params) XXX_Size() int
- func (m *Params) XXX_Unmarshal(b []byte) error
- type Poll
- func (p Poll) AllowOverride()
- func (p Poll) Delete() error
- func (p *Poll) GetKey() exported.PollKey
- func (p Poll) GetResult() codec.ProtoMarshaler
- func (p *Poll) GetTotalVotingPower() sdk.Int
- func (p *Poll) GetVoters() []exported.Voter
- func (p Poll) Initialize() error
- func (p Poll) Is(state exported.PollState) bool
- func (p *Poll) Vote(voter sdk.ValAddress, data codec.ProtoMarshaler) error
- func (p *Poll) WithLogger(logger log.Logger) *Poll
- type Rewarder
- type Snapshotter
- type StakingKeeper
- type Store
- type TalliedVote
- func (*TalliedVote) Descriptor() ([]byte, []int)
- func (m TalliedVote) Hash() string
- func (m *TalliedVote) Marshal() (dAtA []byte, err error)
- func (m *TalliedVote) MarshalTo(dAtA []byte) (int, error)
- func (m *TalliedVote) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*TalliedVote) ProtoMessage()
- func (m *TalliedVote) Reset()
- func (m *TalliedVote) Size() (n int)
- func (m *TalliedVote) String() string
- func (m *TalliedVote) Unmarshal(dAtA []byte) error
- func (m TalliedVote) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error
- func (m *TalliedVote) XXX_DiscardUnknown()
- func (m *TalliedVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TalliedVote) XXX_Merge(src proto.Message)
- func (m *TalliedVote) XXX_Size() int
- func (m *TalliedVote) XXX_Unmarshal(b []byte) error
- type Voters
Constants ¶
const ( // ModuleName is the name of the module ModuleName = "vote" // StoreKey to be used when creating the KVStore StoreKey = ModuleName // RouterKey to be used for routing msgs RouterKey = ModuleName // QuerierRoute to be used for legacy query routing QuerierRoute = ModuleName )
Variables ¶
var ( ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") )
var ( ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") )
var ( ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") )
var (
KeyDefaultVotingThreshold = []byte("DefaultVotingThreshold")
)
Parameter store keys
var ModuleCdc = codec.NewAminoCodec(amino)
ModuleCdc defines the module codec
Functions ¶
func KeyTable ¶ added in v0.9.0
func KeyTable() paramtypes.KeyTable
KeyTable retrieves a subspace table for the module
func NewPollMetaData ¶
func NewPollMetaData(key exported.PollKey, threshold utils.Threshold, voters []exported.Voter, totalVotingPower sdk.Int) exported.PollMetadata
NewPollMetaData is the constructor for PollMetadata. It is not in the exported package to make it clear that only the vote module is supposed to use it.
func RegisterInterfaces ¶
func RegisterInterfaces(cdctypes.InterfaceRegistry)
RegisterInterfaces registers types and interfaces with the given registry
func RegisterLegacyAminoCodec ¶
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)
RegisterLegacyAminoCodec registers concrete types on codec
Types ¶
type GenesisState ¶
type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` PollMetadatas []exported.PollMetadata `protobuf:"bytes,2,rep,name=poll_metadatas,json=pollMetadatas,proto3" json:"poll_metadatas"` }
func DefaultGenesisState ¶
func DefaultGenesisState() *GenesisState
DefaultGenesisState represents the default genesis state
func NewGenesisState ¶ added in v0.9.0
func NewGenesisState(params Params, pollMetadatas []exported.PollMetadata) *GenesisState
NewGenesisState is the constructor for GenesisState
func (*GenesisState) Descriptor ¶
func (*GenesisState) Descriptor() ([]byte, []int)
func (*GenesisState) Marshal ¶
func (m *GenesisState) Marshal() (dAtA []byte, err error)
func (*GenesisState) MarshalToSizedBuffer ¶
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*GenesisState) ProtoMessage ¶
func (*GenesisState) ProtoMessage()
func (*GenesisState) Reset ¶
func (m *GenesisState) Reset()
func (*GenesisState) Size ¶
func (m *GenesisState) Size() (n int)
func (*GenesisState) String ¶
func (m *GenesisState) String() string
func (*GenesisState) Unmarshal ¶
func (m *GenesisState) Unmarshal(dAtA []byte) error
func (GenesisState) Validate ¶
func (m GenesisState) Validate() error
Validate validates the genesis state
func (*GenesisState) XXX_DiscardUnknown ¶
func (m *GenesisState) XXX_DiscardUnknown()
func (*GenesisState) XXX_Marshal ¶
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GenesisState) XXX_Merge ¶
func (m *GenesisState) XXX_Merge(src proto.Message)
func (*GenesisState) XXX_Size ¶
func (m *GenesisState) XXX_Size() int
func (*GenesisState) XXX_Unmarshal ¶
func (m *GenesisState) XXX_Unmarshal(b []byte) error
type Params ¶ added in v0.9.0
type Params struct {
DefaultVotingThreshold utils.Threshold `protobuf:"bytes,1,opt,name=default_voting_threshold,json=defaultVotingThreshold,proto3" json:"default_voting_threshold"`
}
Params represent the genesis parameters for the module
func DefaultParams ¶ added in v0.9.0
func DefaultParams() Params
DefaultParams - the module's default parameters
func (*Params) Descriptor ¶ added in v0.9.0
func (*Params) MarshalToSizedBuffer ¶ added in v0.9.0
func (*Params) ParamSetPairs ¶ added in v0.9.0
func (m *Params) ParamSetPairs() paramtypes.ParamSetPairs
ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of vote module's parameters.
func (*Params) ProtoMessage ¶ added in v0.9.0
func (*Params) ProtoMessage()
func (*Params) XXX_DiscardUnknown ¶ added in v0.9.0
func (m *Params) XXX_DiscardUnknown()
func (*Params) XXX_Marshal ¶ added in v0.9.0
func (*Params) XXX_Unmarshal ¶ added in v0.9.0
type Poll ¶
type Poll struct { exported.PollMetadata Store // contains filtered or unexported fields }
Poll represents a poll with write-in voting
func (Poll) AllowOverride ¶
func (p Poll) AllowOverride()
AllowOverride makes it possible to delete the poll, regardless of which state it is in
func (Poll) Delete ¶
Delete deletes the poll. Returns error if the poll is in a state that does not allow deletion
func (Poll) GetResult ¶
func (p Poll) GetResult() codec.ProtoMarshaler
GetResult returns the result of the poll. Returns nil if the poll is not completed.
func (*Poll) GetTotalVotingPower ¶
GetTotalVotingPower returns the total voting power of the poll
func (*Poll) Vote ¶
func (p *Poll) Vote(voter sdk.ValAddress, data codec.ProtoMarshaler) error
Vote records the given vote
type Rewarder ¶
type Rewarder interface {
GetPool(ctx sdk.Context, name string) reward.RewardPool
}
Rewarder provides reward functionality
type Snapshotter ¶
Snapshotter provides snapshot functionality
type StakingKeeper ¶
type StakingKeeper interface { Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI PowerReduction(sdk.Context) sdk.Int GetLastTotalPower(sdk.Context) sdk.Int }
StakingKeeper provides functionality of the staking module
type Store ¶
type Store interface { SetVote(voter sdk.ValAddress, vote TalliedVote) GetVote(hash string) (TalliedVote, bool) HasVoted(voter sdk.ValAddress) bool GetVotes() []TalliedVote SetMetadata(metadata exported.PollMetadata) GetPoll(key exported.PollKey) exported.Poll DeletePoll() }
Store enables a poll to communicate with the keeper
type TalliedVote ¶
type TalliedVote struct { Tally github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=tally,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"tally"` Voters Voters `protobuf:"bytes,2,rep,name=voters,proto3,castrepeated=Voters" json:"voters,omitempty"` Data *types.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` }
TalliedVote represents a vote for a poll with the accumulated stake of all validators voting for the same data
func NewTalliedVote ¶
func NewTalliedVote(voter sdk.ValAddress, votingPower int64, data codec.ProtoMarshaler) TalliedVote
NewTalliedVote is the constructor for TalliedVote
func (*TalliedVote) Descriptor ¶
func (*TalliedVote) Descriptor() ([]byte, []int)
func (TalliedVote) Hash ¶
func (m TalliedVote) Hash() string
Hash returns the hash of the value of the vote
func (*TalliedVote) Marshal ¶
func (m *TalliedVote) Marshal() (dAtA []byte, err error)
func (*TalliedVote) MarshalToSizedBuffer ¶
func (m *TalliedVote) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*TalliedVote) ProtoMessage ¶
func (*TalliedVote) ProtoMessage()
func (*TalliedVote) Reset ¶
func (m *TalliedVote) Reset()
func (*TalliedVote) Size ¶
func (m *TalliedVote) Size() (n int)
func (*TalliedVote) String ¶
func (m *TalliedVote) String() string
func (*TalliedVote) Unmarshal ¶
func (m *TalliedVote) Unmarshal(dAtA []byte) error
func (TalliedVote) UnpackInterfaces ¶
func (m TalliedVote) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error
UnpackInterfaces implements UnpackInterfacesMessage
func (*TalliedVote) XXX_DiscardUnknown ¶
func (m *TalliedVote) XXX_DiscardUnknown()
func (*TalliedVote) XXX_Marshal ¶
func (m *TalliedVote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*TalliedVote) XXX_Merge ¶
func (m *TalliedVote) XXX_Merge(src proto.Message)
func (*TalliedVote) XXX_Size ¶
func (m *TalliedVote) XXX_Size() int
func (*TalliedVote) XXX_Unmarshal ¶
func (m *TalliedVote) XXX_Unmarshal(b []byte) error
type Voters ¶
type Voters []sdk.ValAddress
Voters is a type alias necessary to unmarshal TalliedVote