Documentation ¶
Overview ¶
Package gov contains on chain governance process protocols.
Index ¶
- Variables
- func RegisterQuery(qr weave.QueryRouter)
- func RegisterRoutes(r weave.Registry, auth x.Authenticator)
- type CreateTextProposalMsg
- func (*CreateTextProposalMsg) Descriptor() ([]byte, []int)
- func (m *CreateTextProposalMsg) GetAuthor() github_com_iov_one_weave.Address
- func (m *CreateTextProposalMsg) GetDescription() string
- func (m *CreateTextProposalMsg) GetElectionRuleID() []byte
- func (m *CreateTextProposalMsg) GetElectorateID() []byte
- func (m *CreateTextProposalMsg) GetStartTime() github_com_iov_one_weave.UnixTime
- func (m *CreateTextProposalMsg) GetTitle() string
- func (m *CreateTextProposalMsg) Marshal() (dAtA []byte, err error)
- func (m *CreateTextProposalMsg) MarshalTo(dAtA []byte) (int, error)
- func (CreateTextProposalMsg) Path() string
- func (*CreateTextProposalMsg) ProtoMessage()
- func (m *CreateTextProposalMsg) Reset()
- func (m *CreateTextProposalMsg) Size() (n int)
- func (m *CreateTextProposalMsg) String() string
- func (m *CreateTextProposalMsg) Unmarshal(dAtA []byte) error
- func (m CreateTextProposalMsg) Validate() error
- func (m *CreateTextProposalMsg) XXX_DiscardUnknown()
- func (m *CreateTextProposalMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CreateTextProposalMsg) XXX_Merge(src proto.Message)
- func (m *CreateTextProposalMsg) XXX_Size() int
- func (m *CreateTextProposalMsg) XXX_Unmarshal(b []byte) error
- type ElectionRule
- func (m ElectionRule) Copy() orm.CloneableData
- func (*ElectionRule) Descriptor() ([]byte, []int)
- func (m *ElectionRule) GetThreshold() Fraction
- func (m *ElectionRule) GetTitle() string
- func (m *ElectionRule) GetVotingPeriodHours() uint32
- func (m *ElectionRule) Marshal() (dAtA []byte, err error)
- func (m *ElectionRule) MarshalTo(dAtA []byte) (int, error)
- func (*ElectionRule) ProtoMessage()
- func (m *ElectionRule) Reset()
- func (m *ElectionRule) Size() (n int)
- func (m *ElectionRule) String() string
- func (m *ElectionRule) Unmarshal(dAtA []byte) error
- func (m ElectionRule) Validate() error
- func (m *ElectionRule) XXX_DiscardUnknown()
- func (m *ElectionRule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ElectionRule) XXX_Merge(src proto.Message)
- func (m *ElectionRule) XXX_Size() int
- func (m *ElectionRule) XXX_Unmarshal(b []byte) error
- type ElectionRulesBucket
- type Elector
- func (*Elector) Descriptor() ([]byte, []int)
- func (m *Elector) GetSignature() github_com_iov_one_weave.Address
- func (m *Elector) GetWeight() uint32
- func (m *Elector) Marshal() (dAtA []byte, err error)
- func (m *Elector) MarshalTo(dAtA []byte) (int, error)
- func (*Elector) ProtoMessage()
- func (m *Elector) Reset()
- func (m *Elector) Size() (n int)
- func (m *Elector) String() string
- func (m *Elector) Unmarshal(dAtA []byte) error
- func (m Elector) Validate() error
- func (m *Elector) XXX_DiscardUnknown()
- func (m *Elector) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Elector) XXX_Merge(src proto.Message)
- func (m *Elector) XXX_Size() int
- func (m *Elector) XXX_Unmarshal(b []byte) error
- type Electorate
- func (m Electorate) Copy() orm.CloneableData
- func (*Electorate) Descriptor() ([]byte, []int)
- func (m Electorate) Elector(a weave.Address) (*Elector, bool)
- func (m *Electorate) GetElectors() []Elector
- func (m *Electorate) GetTitle() string
- func (m *Electorate) GetTotalWeightElectorate() uint64
- func (m *Electorate) Marshal() (dAtA []byte, err error)
- func (m *Electorate) MarshalTo(dAtA []byte) (int, error)
- func (*Electorate) ProtoMessage()
- func (m *Electorate) Reset()
- func (m *Electorate) Size() (n int)
- func (m *Electorate) String() string
- func (m *Electorate) Unmarshal(dAtA []byte) error
- func (m Electorate) Validate() error
- func (m *Electorate) XXX_DiscardUnknown()
- func (m *Electorate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Electorate) XXX_Merge(src proto.Message)
- func (m *Electorate) XXX_Size() int
- func (m *Electorate) XXX_Unmarshal(b []byte) error
- type ElectorateBucket
- type Fraction
- func (*Fraction) Descriptor() ([]byte, []int)
- func (m *Fraction) GetDenominator() uint32
- func (m *Fraction) GetNumerator() uint32
- func (m *Fraction) Marshal() (dAtA []byte, err error)
- func (m *Fraction) MarshalTo(dAtA []byte) (int, error)
- func (*Fraction) ProtoMessage()
- func (m *Fraction) Reset()
- func (m *Fraction) Size() (n int)
- func (m *Fraction) String() string
- func (m *Fraction) Unmarshal(dAtA []byte) error
- func (m Fraction) Validate() error
- func (m *Fraction) XXX_DiscardUnknown()
- func (m *Fraction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Fraction) XXX_Merge(src proto.Message)
- func (m *Fraction) XXX_Size() int
- func (m *Fraction) XXX_Unmarshal(b []byte) error
- type Initializer
- type ProposalBucket
- type TallyHandler
- type TallyMsg
- func (*TallyMsg) Descriptor() ([]byte, []int)
- func (m *TallyMsg) GetProposalID() []byte
- func (m *TallyMsg) Marshal() (dAtA []byte, err error)
- func (m *TallyMsg) MarshalTo(dAtA []byte) (int, error)
- func (TallyMsg) Path() string
- func (*TallyMsg) ProtoMessage()
- func (m *TallyMsg) Reset()
- func (m *TallyMsg) Size() (n int)
- func (m *TallyMsg) String() string
- func (m *TallyMsg) Unmarshal(dAtA []byte) error
- func (m TallyMsg) Validate() error
- func (m *TallyMsg) XXX_DiscardUnknown()
- func (m *TallyMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TallyMsg) XXX_Merge(src proto.Message)
- func (m *TallyMsg) XXX_Size() int
- func (m *TallyMsg) XXX_Unmarshal(b []byte) error
- type TallyResult
- func (m TallyResult) Accepted() bool
- func (*TallyResult) Descriptor() ([]byte, []int)
- func (m *TallyResult) GetThreshold() Fraction
- func (m *TallyResult) GetTotalAbstain() uint32
- func (m *TallyResult) GetTotalNo() uint32
- func (m *TallyResult) GetTotalWeightElectorate() uint64
- func (m *TallyResult) GetTotalYes() uint32
- func (m *TallyResult) Marshal() (dAtA []byte, err error)
- func (m *TallyResult) MarshalTo(dAtA []byte) (int, error)
- func (*TallyResult) ProtoMessage()
- func (m *TallyResult) Reset()
- func (m *TallyResult) Size() (n int)
- func (m *TallyResult) String() string
- func (m *TallyResult) Unmarshal(dAtA []byte) error
- func (m *TallyResult) XXX_DiscardUnknown()
- func (m *TallyResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TallyResult) XXX_Merge(src proto.Message)
- func (m *TallyResult) XXX_Size() int
- func (m *TallyResult) XXX_Unmarshal(b []byte) error
- type TextProposal
- func (m TextProposal) Copy() orm.CloneableData
- func (*TextProposal) Descriptor() ([]byte, []int)
- func (m *TextProposal) GetAuthor() github_com_iov_one_weave.Address
- func (m *TextProposal) GetDescription() string
- func (m *TextProposal) GetElectionRuleID() []byte
- func (m *TextProposal) GetElectorateID() []byte
- func (m *TextProposal) GetStatus() TextProposal_Status
- func (m *TextProposal) GetSubmissionTime() github_com_iov_one_weave.UnixTime
- func (m *TextProposal) GetTitle() string
- func (m *TextProposal) GetVoteResult() TallyResult
- func (m *TextProposal) GetVotes() []*Vote
- func (m *TextProposal) GetVotingEndTime() github_com_iov_one_weave.UnixTime
- func (m *TextProposal) GetVotingStartTime() github_com_iov_one_weave.UnixTime
- func (m TextProposal) HasVoted(a weave.Address) bool
- func (m *TextProposal) Marshal() (dAtA []byte, err error)
- func (m *TextProposal) MarshalTo(dAtA []byte) (int, error)
- func (*TextProposal) ProtoMessage()
- func (m *TextProposal) Reset()
- func (m *TextProposal) Size() (n int)
- func (m *TextProposal) String() string
- func (m *TextProposal) Tally() error
- func (m *TextProposal) Unmarshal(dAtA []byte) error
- func (m *TextProposal) Validate() error
- func (m *TextProposal) Vote(voted VoteOption, elector Elector) error
- func (m *TextProposal) XXX_DiscardUnknown()
- func (m *TextProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *TextProposal) XXX_Merge(src proto.Message)
- func (m *TextProposal) XXX_Size() int
- func (m *TextProposal) XXX_Unmarshal(b []byte) error
- type TextProposalHandler
- type TextProposal_Status
- type Vote
- func (*Vote) Descriptor() ([]byte, []int)
- func (m *Vote) GetElector() Elector
- func (m *Vote) GetVoted() VoteOption
- func (m *Vote) Marshal() (dAtA []byte, err error)
- func (m *Vote) MarshalTo(dAtA []byte) (int, error)
- func (*Vote) ProtoMessage()
- func (m *Vote) Reset()
- func (m *Vote) Size() (n int)
- func (m *Vote) String() string
- func (m *Vote) Unmarshal(dAtA []byte) error
- func (m *Vote) XXX_DiscardUnknown()
- func (m *Vote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Vote) XXX_Merge(src proto.Message)
- func (m *Vote) XXX_Size() int
- func (m *Vote) XXX_Unmarshal(b []byte) error
- type VoteHandler
- type VoteMsg
- func (*VoteMsg) Descriptor() ([]byte, []int)
- func (m *VoteMsg) GetProposalID() []byte
- func (m *VoteMsg) GetSelected() VoteOption
- func (m *VoteMsg) GetVoter() github_com_iov_one_weave.Address
- func (m *VoteMsg) Marshal() (dAtA []byte, err error)
- func (m *VoteMsg) MarshalTo(dAtA []byte) (int, error)
- func (VoteMsg) Path() string
- func (*VoteMsg) ProtoMessage()
- func (m *VoteMsg) Reset()
- func (m *VoteMsg) Size() (n int)
- func (m *VoteMsg) String() string
- func (m *VoteMsg) Unmarshal(dAtA []byte) error
- func (m VoteMsg) Validate() error
- func (m *VoteMsg) XXX_DiscardUnknown()
- func (m *VoteMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *VoteMsg) XXX_Merge(src proto.Message)
- func (m *VoteMsg) XXX_Size() int
- func (m *VoteMsg) XXX_Unmarshal(b []byte) error
- type VoteOption
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowCodec = fmt.Errorf("proto: integer overflow") )
var TextProposal_Status_name = map[int32]string{
0: "TEXT_PROPOSAL_STATUS_INVALID",
1: "TEXT_PROPOSAL_STATUS_UNDEFINED",
2: "TEXT_PROPOSAL_STATUS_ACCEPTED",
3: "TEXT_PROPOSAL_STATUS_REJECTED",
}
var TextProposal_Status_value = map[string]int32{
"TEXT_PROPOSAL_STATUS_INVALID": 0,
"TEXT_PROPOSAL_STATUS_UNDEFINED": 1,
"TEXT_PROPOSAL_STATUS_ACCEPTED": 2,
"TEXT_PROPOSAL_STATUS_REJECTED": 3,
}
var VoteOption_name = map[int32]string{
0: "VOTE_OPTION_INVALID",
1: "VOTE_OPTION_YES",
2: "VOTE_OPTION_NO",
3: "VOTE_OPTION_ABSTAIN",
}
var VoteOption_value = map[string]int32{
"VOTE_OPTION_INVALID": 0,
"VOTE_OPTION_YES": 1,
"VOTE_OPTION_NO": 2,
"VOTE_OPTION_ABSTAIN": 3,
}
Functions ¶
func RegisterQuery ¶
func RegisterQuery(qr weave.QueryRouter)
RegisterQuery registers governance buckets for querying.
func RegisterRoutes ¶
func RegisterRoutes(r weave.Registry, auth x.Authenticator)
RegisterRoutes registers handlers for governance message processing.
Types ¶
type CreateTextProposalMsg ¶
type CreateTextProposalMsg struct { // Human readable title. Must match `^[a-zA-Z0-9 _.-]{4,128}$` Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // Human readable description with 3 to 5000 chars. Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // Reference to the election rule ElectionRuleID []byte `protobuf:"bytes,3,opt,name=election_rule_id,json=electionRuleId,proto3" json:"election_rule_id,omitempty"` // Reference to the electorate to define the group of possible voters. ElectorateID []byte `protobuf:"bytes,4,opt,name=electorate_id,json=electorateId,proto3" json:"electorate_id,omitempty"` // Unix timestamp when the proposal starts. Must be in the future. StartTime github_com_iov_one_weave.UnixTime `` /* 132-byte string literal not displayed */ // Author is an optional field to set the address of the author with a proposal. The author must sign the message. // When not set it will default to the main signer. Author github_com_iov_one_weave.Address `protobuf:"bytes,8,opt,name=author,proto3,casttype=github.com/iov-one/weave.Address" json:"author,omitempty"` }
CreateTextProposalMsg creates a new governance proposal.
func (*CreateTextProposalMsg) Descriptor ¶
func (*CreateTextProposalMsg) Descriptor() ([]byte, []int)
func (*CreateTextProposalMsg) GetAuthor ¶
func (m *CreateTextProposalMsg) GetAuthor() github_com_iov_one_weave.Address
func (*CreateTextProposalMsg) GetDescription ¶
func (m *CreateTextProposalMsg) GetDescription() string
func (*CreateTextProposalMsg) GetElectionRuleID ¶
func (m *CreateTextProposalMsg) GetElectionRuleID() []byte
func (*CreateTextProposalMsg) GetElectorateID ¶
func (m *CreateTextProposalMsg) GetElectorateID() []byte
func (*CreateTextProposalMsg) GetStartTime ¶
func (m *CreateTextProposalMsg) GetStartTime() github_com_iov_one_weave.UnixTime
func (*CreateTextProposalMsg) GetTitle ¶
func (m *CreateTextProposalMsg) GetTitle() string
func (*CreateTextProposalMsg) Marshal ¶
func (m *CreateTextProposalMsg) Marshal() (dAtA []byte, err error)
func (*CreateTextProposalMsg) MarshalTo ¶
func (m *CreateTextProposalMsg) MarshalTo(dAtA []byte) (int, error)
func (CreateTextProposalMsg) Path ¶
func (CreateTextProposalMsg) Path() string
func (*CreateTextProposalMsg) ProtoMessage ¶
func (*CreateTextProposalMsg) ProtoMessage()
func (*CreateTextProposalMsg) Reset ¶
func (m *CreateTextProposalMsg) Reset()
func (*CreateTextProposalMsg) Size ¶
func (m *CreateTextProposalMsg) Size() (n int)
func (*CreateTextProposalMsg) String ¶
func (m *CreateTextProposalMsg) String() string
func (*CreateTextProposalMsg) Unmarshal ¶
func (m *CreateTextProposalMsg) Unmarshal(dAtA []byte) error
func (CreateTextProposalMsg) Validate ¶
func (m CreateTextProposalMsg) Validate() error
func (*CreateTextProposalMsg) XXX_DiscardUnknown ¶
func (m *CreateTextProposalMsg) XXX_DiscardUnknown()
func (*CreateTextProposalMsg) XXX_Marshal ¶
func (m *CreateTextProposalMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*CreateTextProposalMsg) XXX_Merge ¶
func (m *CreateTextProposalMsg) XXX_Merge(src proto.Message)
func (*CreateTextProposalMsg) XXX_Size ¶
func (m *CreateTextProposalMsg) XXX_Size() int
func (*CreateTextProposalMsg) XXX_Unmarshal ¶
func (m *CreateTextProposalMsg) XXX_Unmarshal(b []byte) error
type ElectionRule ¶
type ElectionRule struct { // Human readable title. Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // Duration how long the voting period will take place. VotingPeriodHours uint32 `protobuf:"varint,3,opt,name=voting_period_hours,json=votingPeriodHours,proto3" json:"voting_period_hours,omitempty"` // Threshold is the fraction of all eligible voters, not only the ones who voted. To accept a // proposal this value must be exceeded. // The formula is `(yes*denominator) > (numerator*total_electors_weight)`. // The valid range for the threshold value is `0.5` to `1` (inclusive) which allows any value between half and all // of the eligible voters. Threshold Fraction `protobuf:"bytes,4,opt,name=threshold,proto3" json:"threshold"` }
Election Rule defines how an election is run. A proposal must be voted upon via a pre-defined ruleset.
func (ElectionRule) Copy ¶
func (m ElectionRule) Copy() orm.CloneableData
func (*ElectionRule) Descriptor ¶
func (*ElectionRule) Descriptor() ([]byte, []int)
func (*ElectionRule) GetThreshold ¶
func (m *ElectionRule) GetThreshold() Fraction
func (*ElectionRule) GetTitle ¶
func (m *ElectionRule) GetTitle() string
func (*ElectionRule) GetVotingPeriodHours ¶
func (m *ElectionRule) GetVotingPeriodHours() uint32
func (*ElectionRule) Marshal ¶
func (m *ElectionRule) Marshal() (dAtA []byte, err error)
func (*ElectionRule) ProtoMessage ¶
func (*ElectionRule) ProtoMessage()
func (*ElectionRule) Reset ¶
func (m *ElectionRule) Reset()
func (*ElectionRule) Size ¶
func (m *ElectionRule) Size() (n int)
func (*ElectionRule) String ¶
func (m *ElectionRule) String() string
func (*ElectionRule) Unmarshal ¶
func (m *ElectionRule) Unmarshal(dAtA []byte) error
func (ElectionRule) Validate ¶
func (m ElectionRule) Validate() error
func (*ElectionRule) XXX_DiscardUnknown ¶
func (m *ElectionRule) XXX_DiscardUnknown()
func (*ElectionRule) XXX_Marshal ¶
func (m *ElectionRule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ElectionRule) XXX_Merge ¶
func (m *ElectionRule) XXX_Merge(src proto.Message)
func (*ElectionRule) XXX_Size ¶
func (m *ElectionRule) XXX_Size() int
func (*ElectionRule) XXX_Unmarshal ¶
func (m *ElectionRule) XXX_Unmarshal(b []byte) error
type ElectionRulesBucket ¶
NewElectionRulesBucket is the persistent bucket for ElectionRules .
func NewElectionRulesBucket ¶
func NewElectionRulesBucket() *ElectionRulesBucket
NewElectionRulesBucket returns a bucket for managing election rules.
func (*ElectionRulesBucket) Build ¶
func (b *ElectionRulesBucket) Build(db weave.KVStore, r *ElectionRule) orm.Object
Build assigns an ID to given election rule instance and returns it as an orm Object. It does not persist the object in the store.
func (*ElectionRulesBucket) GetElectionRule ¶
func (b *ElectionRulesBucket) GetElectionRule(db weave.KVStore, id []byte) (*ElectionRule, error)
GetElectionRule loads the electorate for the given id. If it does not exist then ErrNotFound is returned.
type Elector ¶
type Elector struct { // The address of the voter. Signature github_com_iov_one_weave.Address `protobuf:"bytes,1,opt,name=signature,proto3,casttype=github.com/iov-one/weave.Address" json:"signature,omitempty"` // Weight defines the power of the participants vote. max value is 65535 (2^16-1). Weight uint32 `protobuf:"varint,2,opt,name=weight,proto3" json:"weight,omitempty"` }
Elector clubs together a signature with a weight. The greater the weight the greater the power of a participant.
func (*Elector) Descriptor ¶
func (*Elector) GetSignature ¶
func (m *Elector) GetSignature() github_com_iov_one_weave.Address
func (*Elector) ProtoMessage ¶
func (*Elector) ProtoMessage()
func (*Elector) XXX_DiscardUnknown ¶
func (m *Elector) XXX_DiscardUnknown()
func (*Elector) XXX_Marshal ¶
func (*Elector) XXX_Unmarshal ¶
type Electorate ¶
type Electorate struct { // Human readable title. Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // Elector defines a list of all signatures that are allowed to participate in a vote Electors []Elector `protobuf:"bytes,2,rep,name=electors,proto3" json:"electors"` // TotalWeightElectorate is the sum of all electors weights. TotalWeightElectorate uint64 `protobuf:"varint,3,opt,name=TotalWeightElectorate,proto3" json:"TotalWeightElectorate,omitempty"` }
Electorate defines who may vote in an election. This same group can be used in many elections and is stored for re-use
func (Electorate) Copy ¶
func (m Electorate) Copy() orm.CloneableData
func (*Electorate) Descriptor ¶
func (*Electorate) Descriptor() ([]byte, []int)
func (Electorate) Elector ¶
func (m Electorate) Elector(a weave.Address) (*Elector, bool)
Weight return the weight for the given address is in the electors list and an ok flag which is true when the address exists in the electors list only.
func (*Electorate) GetElectors ¶
func (m *Electorate) GetElectors() []Elector
func (*Electorate) GetTitle ¶
func (m *Electorate) GetTitle() string
func (*Electorate) GetTotalWeightElectorate ¶
func (m *Electorate) GetTotalWeightElectorate() uint64
func (*Electorate) Marshal ¶
func (m *Electorate) Marshal() (dAtA []byte, err error)
func (*Electorate) ProtoMessage ¶
func (*Electorate) ProtoMessage()
func (*Electorate) Reset ¶
func (m *Electorate) Reset()
func (*Electorate) Size ¶
func (m *Electorate) Size() (n int)
func (*Electorate) String ¶
func (m *Electorate) String() string
func (*Electorate) Unmarshal ¶
func (m *Electorate) Unmarshal(dAtA []byte) error
func (Electorate) Validate ¶
func (m Electorate) Validate() error
func (*Electorate) XXX_DiscardUnknown ¶
func (m *Electorate) XXX_DiscardUnknown()
func (*Electorate) XXX_Marshal ¶
func (m *Electorate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Electorate) XXX_Merge ¶
func (m *Electorate) XXX_Merge(src proto.Message)
func (*Electorate) XXX_Size ¶
func (m *Electorate) XXX_Size() int
func (*Electorate) XXX_Unmarshal ¶
func (m *Electorate) XXX_Unmarshal(b []byte) error
type ElectorateBucket ¶
ElectorateBucket is the persistent bucket for Electorate object.
func NewElectorateBucket ¶
func NewElectorateBucket() *ElectorateBucket
NewRevenueBucket returns a bucket for managing electorate.
func (*ElectorateBucket) Build ¶
func (b *ElectorateBucket) Build(db weave.KVStore, e *Electorate) orm.Object
Build assigns an ID to given electorate instance and returns it as an orm Object. It does not persist the object in the store.
func (*ElectorateBucket) GetElectorate ¶
func (b *ElectorateBucket) GetElectorate(db weave.KVStore, id []byte) (*Electorate, error)
GetElectorate loads the electorate for the given id. If it does not exist then ErrNotFound is returned.
type Fraction ¶
type Fraction struct { // The top number in a fraction. Numerator uint32 `protobuf:"varint,1,opt,name=numerator,proto3" json:"numerator,omitempty"` // The bottom number Denominator uint32 `protobuf:"varint,2,opt,name=denominator,proto3" json:"denominator,omitempty"` }
The Fraction type represents a numerator and denominator to enable higher precision thresholds in the election rules. For example: numerator: 1, denominator: 2 => > 50% numerator: 2, denominator: 3 => > 66.666..% numerator: 6273, denominator: 10000 => > 62.73% Valid range of the fraction is 0.5 to 1.
func (*Fraction) Descriptor ¶
func (*Fraction) GetDenominator ¶
func (*Fraction) GetNumerator ¶
func (*Fraction) ProtoMessage ¶
func (*Fraction) ProtoMessage()
func (*Fraction) XXX_DiscardUnknown ¶
func (m *Fraction) XXX_DiscardUnknown()
func (*Fraction) XXX_Marshal ¶
func (*Fraction) XXX_Unmarshal ¶
type Initializer ¶
type Initializer struct{}
Initializer fulfils the Initializer interface to load data from the genesis file
func (*Initializer) FromGenesis ¶
FromGenesis will parse initial governance electorate and election rules from genesis and saves it in the database.
type ProposalBucket ¶
TextProposalBucket is the persistent bucket for TextProposal objects.
func NewProposalBucket ¶
func NewProposalBucket() *ProposalBucket
NewRevenueBucket returns a bucket for managing electorate.
func (*ProposalBucket) Build ¶
func (b *ProposalBucket) Build(db weave.KVStore, e *TextProposal) orm.Object
Build assigns an ID to given proposal instance and returns it as an orm Object. It does not persist the object in the store.
func (*ProposalBucket) GetTextProposal ¶
func (b *ProposalBucket) GetTextProposal(db weave.KVStore, id []byte) (*TextProposal, error)
GetElectionRule loads the electorate for the given id. If it does not exist then ErrNotFound is returned.
func (*ProposalBucket) Update ¶
func (b *ProposalBucket) Update(db weave.KVStore, id []byte, obj *TextProposal) error
Update stores the given proposal and id in the persistence store.
type TallyHandler ¶
type TallyHandler struct {
// contains filtered or unexported fields
}
type TallyMsg ¶
type TallyMsg struct { // ProposalID is UUID of the proposal to close. ProposalID []byte `protobuf:"bytes,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` }
TallyMsg can be sent after the voting period has ended to do the final tally and trigger any state changes. A final tally can be execute only once. A second submission will fail with an invalid state error.
func (*TallyMsg) Descriptor ¶
func (*TallyMsg) GetProposalID ¶
func (*TallyMsg) ProtoMessage ¶
func (*TallyMsg) ProtoMessage()
func (*TallyMsg) XXX_DiscardUnknown ¶
func (m *TallyMsg) XXX_DiscardUnknown()
func (*TallyMsg) XXX_Marshal ¶
func (*TallyMsg) XXX_Unmarshal ¶
type TallyResult ¶
type TallyResult struct { // Sum of weights of all the voters that approved the proposal TotalYes uint32 `protobuf:"varint,1,opt,name=total_yes,json=totalYes,proto3" json:"total_yes,omitempty"` // Sum of weights of all the voters that rejected the proposal TotalNo uint32 `protobuf:"varint,2,opt,name=total_no,json=totalNo,proto3" json:"total_no,omitempty"` // Sum of weights of all the voters that voted abstain TotalAbstain uint32 `protobuf:"varint,3,opt,name=total_abstain,json=totalAbstain,proto3" json:"total_abstain,omitempty"` // Sum of all weights in the electorate. TotalWeightElectorate uint64 `` /* 127-byte string literal not displayed */ // Threshold is the fraction of all eligible voters, not only the ones who voted. To accept a // proposal this value must be exceeded. Threshold Fraction `protobuf:"bytes,5,opt,name=threshold,proto3" json:"threshold"` }
TallyResult contains sums of the votes and all data for the final result.
func (TallyResult) Accepted ¶
func (m TallyResult) Accepted() bool
Accepted returns the result of the `(yes*denominator) > (numerator*total_electors_weight)` calculation.
func (*TallyResult) Descriptor ¶
func (*TallyResult) Descriptor() ([]byte, []int)
func (*TallyResult) GetThreshold ¶
func (m *TallyResult) GetThreshold() Fraction
func (*TallyResult) GetTotalAbstain ¶
func (m *TallyResult) GetTotalAbstain() uint32
func (*TallyResult) GetTotalNo ¶
func (m *TallyResult) GetTotalNo() uint32
func (*TallyResult) GetTotalWeightElectorate ¶
func (m *TallyResult) GetTotalWeightElectorate() uint64
func (*TallyResult) GetTotalYes ¶
func (m *TallyResult) GetTotalYes() uint32
func (*TallyResult) Marshal ¶
func (m *TallyResult) Marshal() (dAtA []byte, err error)
func (*TallyResult) ProtoMessage ¶
func (*TallyResult) ProtoMessage()
func (*TallyResult) Reset ¶
func (m *TallyResult) Reset()
func (*TallyResult) Size ¶
func (m *TallyResult) Size() (n int)
func (*TallyResult) String ¶
func (m *TallyResult) String() string
func (*TallyResult) Unmarshal ¶
func (m *TallyResult) Unmarshal(dAtA []byte) error
func (*TallyResult) XXX_DiscardUnknown ¶
func (m *TallyResult) XXX_DiscardUnknown()
func (*TallyResult) XXX_Marshal ¶
func (m *TallyResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*TallyResult) XXX_Merge ¶
func (m *TallyResult) XXX_Merge(src proto.Message)
func (*TallyResult) XXX_Size ¶
func (m *TallyResult) XXX_Size() int
func (*TallyResult) XXX_Unmarshal ¶
func (m *TallyResult) XXX_Unmarshal(b []byte) error
type TextProposal ¶
type TextProposal struct { // Human readable title. Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // Description of the proposal in text form. Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // Reference to the election rule ElectionRuleID []byte `protobuf:"bytes,3,opt,name=election_rule_id,json=electionRuleId,proto3" json:"election_rule_id,omitempty"` // Reference to the electorate to define the group of possible voters. ElectorateID []byte `protobuf:"bytes,4,opt,name=electorate_id,json=electorateId,proto3" json:"electorate_id,omitempty"` // Unix timestamp of the block where the voting period starts. Header time of the votes must be greater than or equal // to this start time. VotingStartTime github_com_iov_one_weave.UnixTime `` /* 152-byte string literal not displayed */ // Unix timestamp of the block where the voting period ends. Header times of the votes must be before this end time // to be included in the election. VotingEndTime github_com_iov_one_weave.UnixTime `` /* 146-byte string literal not displayed */ // Unix timestamp of the block where the proposal was added to the chain. SubmissionTime github_com_iov_one_weave.UnixTime `` /* 147-byte string literal not displayed */ // Address of the author who created the proposal. If not set explicit on creation it will default to the main signer. Author github_com_iov_one_weave.Address `protobuf:"bytes,8,opt,name=author,proto3,casttype=github.com/iov-one/weave.Address" json:"author,omitempty"` // Votes contain the list of individual votes with elector and voted option. Votes []*Vote `protobuf:"bytes,9,rep,name=votes,proto3" json:"votes,omitempty"` // Result of the election. Contains intermediate tally results while voting period is open. VoteResult TallyResult `protobuf:"bytes,10,opt,name=vote_result,json=voteResult,proto3" json:"vote_result"` // status is the final result based on the votes and election rule. Status TextProposal_Status `protobuf:"varint,11,opt,name=status,proto3,enum=gov.TextProposal_Status" json:"status,omitempty"` }
A text form proposal for an on-chain governance process.
func (TextProposal) Copy ¶
func (m TextProposal) Copy() orm.CloneableData
func (*TextProposal) Descriptor ¶
func (*TextProposal) Descriptor() ([]byte, []int)
func (*TextProposal) GetAuthor ¶
func (m *TextProposal) GetAuthor() github_com_iov_one_weave.Address
func (*TextProposal) GetDescription ¶
func (m *TextProposal) GetDescription() string
func (*TextProposal) GetElectionRuleID ¶
func (m *TextProposal) GetElectionRuleID() []byte
func (*TextProposal) GetElectorateID ¶
func (m *TextProposal) GetElectorateID() []byte
func (*TextProposal) GetStatus ¶
func (m *TextProposal) GetStatus() TextProposal_Status
func (*TextProposal) GetSubmissionTime ¶
func (m *TextProposal) GetSubmissionTime() github_com_iov_one_weave.UnixTime
func (*TextProposal) GetTitle ¶
func (m *TextProposal) GetTitle() string
func (*TextProposal) GetVoteResult ¶
func (m *TextProposal) GetVoteResult() TallyResult
func (*TextProposal) GetVotes ¶
func (m *TextProposal) GetVotes() []*Vote
func (*TextProposal) GetVotingEndTime ¶
func (m *TextProposal) GetVotingEndTime() github_com_iov_one_weave.UnixTime
func (*TextProposal) GetVotingStartTime ¶
func (m *TextProposal) GetVotingStartTime() github_com_iov_one_weave.UnixTime
func (TextProposal) HasVoted ¶
func (m TextProposal) HasVoted(a weave.Address) bool
HasVoted returns if the given address has been in the voter archive for this proposal.
func (*TextProposal) Marshal ¶
func (m *TextProposal) Marshal() (dAtA []byte, err error)
func (*TextProposal) ProtoMessage ¶
func (*TextProposal) ProtoMessage()
func (*TextProposal) Reset ¶
func (m *TextProposal) Reset()
func (*TextProposal) Size ¶
func (m *TextProposal) Size() (n int)
func (*TextProposal) String ¶
func (m *TextProposal) String() string
func (*TextProposal) Tally ¶
func (m *TextProposal) Tally() error
Tally calls the final calculation on the votes and sets the status of the proposal according to the election rules threshold.
func (*TextProposal) Unmarshal ¶
func (m *TextProposal) Unmarshal(dAtA []byte) error
func (*TextProposal) Validate ¶
func (m *TextProposal) Validate() error
func (*TextProposal) Vote ¶
func (m *TextProposal) Vote(voted VoteOption, elector Elector) error
Vote updates the intermediate tally result with the new vote and stores the elector in the voter archive.
func (*TextProposal) XXX_DiscardUnknown ¶
func (m *TextProposal) XXX_DiscardUnknown()
func (*TextProposal) XXX_Marshal ¶
func (m *TextProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*TextProposal) XXX_Merge ¶
func (m *TextProposal) XXX_Merge(src proto.Message)
func (*TextProposal) XXX_Size ¶
func (m *TextProposal) XXX_Size() int
func (*TextProposal) XXX_Unmarshal ¶
func (m *TextProposal) XXX_Unmarshal(b []byte) error
type TextProposalHandler ¶
type TextProposalHandler struct {
// contains filtered or unexported fields
}
type TextProposal_Status ¶
type TextProposal_Status int32
Status of the proposal base on the final tally result. `UNDEFINED` as initial value.
const ( TextProposal_Invalid TextProposal_Status = 0 TextProposal_Undefined TextProposal_Status = 1 TextProposal_Accepted TextProposal_Status = 2 TextProposal_Rejected TextProposal_Status = 3 )
func (TextProposal_Status) EnumDescriptor ¶
func (TextProposal_Status) EnumDescriptor() ([]byte, []int)
func (TextProposal_Status) String ¶
func (x TextProposal_Status) String() string
type Vote ¶
type Vote struct { Elector Elector `protobuf:"bytes,1,opt,name=elector,proto3" json:"elector"` Voted VoteOption `protobuf:"varint,2,opt,name=voted,proto3,enum=gov.VoteOption" json:"voted,omitempty"` }
Vote combines the elector and his voted option to archive them.
func (*Vote) Descriptor ¶
func (*Vote) GetElector ¶
func (*Vote) GetVoted ¶
func (m *Vote) GetVoted() VoteOption
func (*Vote) ProtoMessage ¶
func (*Vote) ProtoMessage()
func (*Vote) XXX_DiscardUnknown ¶
func (m *Vote) XXX_DiscardUnknown()
func (*Vote) XXX_Unmarshal ¶
type VoteHandler ¶
type VoteHandler struct {
// contains filtered or unexported fields
}
type VoteMsg ¶
type VoteMsg struct { // The unique id of the proposal. ProposalID []byte `protobuf:"bytes,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // voter address is an optional field. When not set the main signer will be used as default. The voter address // must be included in the electorate for a valid vote. Voter github_com_iov_one_weave.Address `protobuf:"bytes,2,opt,name=voter,proto3,casttype=github.com/iov-one/weave.Address" json:"voter,omitempty"` // Option for the vote. Must be Yes, No or Abstain for a valid vote. Selected VoteOption `protobuf:"varint,3,opt,name=selected,proto3,enum=gov.VoteOption" json:"selected,omitempty"` }
VoteMsg is the way to express a voice and participate in an election of a proposal on chain.
func (*VoteMsg) Descriptor ¶
func (*VoteMsg) GetProposalID ¶
func (*VoteMsg) GetSelected ¶
func (m *VoteMsg) GetSelected() VoteOption
func (*VoteMsg) GetVoter ¶
func (m *VoteMsg) GetVoter() github_com_iov_one_weave.Address
func (*VoteMsg) ProtoMessage ¶
func (*VoteMsg) ProtoMessage()
func (*VoteMsg) XXX_DiscardUnknown ¶
func (m *VoteMsg) XXX_DiscardUnknown()
func (*VoteMsg) XXX_Marshal ¶
func (*VoteMsg) XXX_Unmarshal ¶
type VoteOption ¶
type VoteOption int32
VoteOptions define possible values for a vote including the INVALID default.
const ( VoteOption_Invalid VoteOption = 0 VoteOption_Yes VoteOption = 1 VoteOption_No VoteOption = 2 VoteOption_Abstain VoteOption = 3 )
func (VoteOption) EnumDescriptor ¶
func (VoteOption) EnumDescriptor() ([]byte, []int)
func (VoteOption) String ¶
func (x VoteOption) String() string