gov

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Overview

Package gov contains on chain governance process protocols.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCodec   = fmt.Errorf("proto: integer overflow")
)
View Source
var Proposal_ExecutorResult_name = map[int32]string{
	0: "PROPOSAL_EXECUTOR_RESULT_INVALID",
	1: "PROPOSAL_EXECUTOR_RESULT_NOT_RUN",
	2: "PROPOSAL_EXECUTOR_RESULT_SUCCESS",
	3: "PROPOSAL_EXECUTOR_RESULT_FAILURE",
}
View Source
var Proposal_ExecutorResult_value = map[string]int32{
	"PROPOSAL_EXECUTOR_RESULT_INVALID": 0,
	"PROPOSAL_EXECUTOR_RESULT_NOT_RUN": 1,
	"PROPOSAL_EXECUTOR_RESULT_SUCCESS": 2,
	"PROPOSAL_EXECUTOR_RESULT_FAILURE": 3,
}
View Source
var Proposal_Result_name = map[int32]string{
	0: "PROPOSAL_RESULT_INVALID",
	1: "PROPOSAL_RESULT_UNDEFINED",
	2: "PROPOSAL_RESULT_ACCEPTED",
	3: "PROPOSAL_RESULT_REJECTED",
}
View Source
var Proposal_Result_value = map[string]int32{
	"PROPOSAL_RESULT_INVALID":   0,
	"PROPOSAL_RESULT_UNDEFINED": 1,
	"PROPOSAL_RESULT_ACCEPTED":  2,
	"PROPOSAL_RESULT_REJECTED":  3,
}
View Source
var Proposal_Status_name = map[int32]string{
	0: "PROPOSAL_STATUS_INVALID",
	1: "PROPOSAL_STATUS_SUBMITTED",
	2: "PROPOSAL_STATUS_CLOSED",
	3: "PROPOSAL_STATUS_WITHDRAWN",
}
View Source
var Proposal_Status_value = map[string]int32{
	"PROPOSAL_STATUS_INVALID":   0,
	"PROPOSAL_STATUS_SUBMITTED": 1,
	"PROPOSAL_STATUS_CLOSED":    2,
	"PROPOSAL_STATUS_WITHDRAWN": 3,
}
View Source
var VoteOption_name = map[int32]string{
	0: "VOTE_OPTION_INVALID",
	1: "VOTE_OPTION_YES",
	2: "VOTE_OPTION_NO",
	3: "VOTE_OPTION_ABSTAIN",
}
View Source
var VoteOption_value = map[string]int32{
	"VOTE_OPTION_INVALID": 0,
	"VOTE_OPTION_YES":     1,
	"VOTE_OPTION_NO":      2,
	"VOTE_OPTION_ABSTAIN": 3,
}

Functions

func Condition added in v0.19.0

func Condition(key []byte) weave.Condition

Condition calculates the address of an election rule given the key

func ElectionCondition added in v0.16.0

func ElectionCondition(ruleID []byte) weave.Condition

ElectionCondition returns condition for an election rule ID.

func RegisterBasicProposalRouters added in v0.16.0

func RegisterBasicProposalRouters(r weave.Registry, auth x.Authenticator)

RegisterBasicProposalRouters register the routes we accept for executing governance decisions.

func RegisterCronRoutes added in v0.19.0

func RegisterCronRoutes(
	r weave.Registry,
	auth x.Authenticator,
	decoder OptionDecoder,
	executor Executor,
)

func RegisterQuery

func RegisterQuery(qr weave.QueryRouter)

RegisterQuery registers governance buckets for querying.

func RegisterRoutes

func RegisterRoutes(
	r weave.Registry,
	auth x.Authenticator,
	decoder OptionDecoder,
	executor Executor,
	scheduler weave.Scheduler,
)

RegisterRoutes registers handlers for governance message processing.

Types

type Authenticate added in v0.16.0

type Authenticate struct {
}

Authenticate gets/sets permissions on the given context key.

func (Authenticate) GetConditions added in v0.16.0

func (a Authenticate) GetConditions(ctx weave.Context) []weave.Condition

GetConditions returns permissions previously set on this context.

func (Authenticate) HasAddress added in v0.16.0

func (a Authenticate) HasAddress(ctx weave.Context, addr weave.Address) bool

HasAddress returns true iff this address is in GetConditions.

type CreateProposalHandler added in v0.16.0

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

func (CreateProposalHandler) Check added in v0.16.0

func (CreateProposalHandler) Deliver added in v0.16.0

type CreateProposalMsg added in v0.16.0

type CreateProposalMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Human readable title. Must match `^[a-zA-Z0-9 _.-]{4,128}$`
	Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
	// Content of the proposal. Protobuf encoded, app-specific decoded must be passed in handler constructor
	RawOption []byte `protobuf:"bytes,3,opt,name=raw_option,json=rawOption,proto3" json:"raw_option,omitempty"`
	// Human readable description with 3 to 5000 chars.
	Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
	// ElectionRuleID is a reference to the election rule
	ElectionRuleID []byte `protobuf:"bytes,5,opt,name=election_rule_id,json=electionRuleId,proto3" json:"election_rule_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.
	// The author of the created proposal.
	// Warning: This field is optional and when not set it will default to any
	// signer. It is recommended to always explicitely set the value of this
	// field, as the signer order is not guaranteed.
	Author github_com_iov_one_weave.Address `protobuf:"bytes,7,opt,name=author,proto3,casttype=github.com/iov-one/weave.Address" json:"author,omitempty"`
}

CreateProposalMsg creates a new governance proposal. Most fields control the whole election process. raw_option contains an transaction to be executed by the governance vote in case of success (what is being voted on)

func (*CreateProposalMsg) Descriptor added in v0.16.0

func (*CreateProposalMsg) Descriptor() ([]byte, []int)

func (*CreateProposalMsg) GetAuthor added in v0.16.0

func (*CreateProposalMsg) GetDescription added in v0.16.0

func (m *CreateProposalMsg) GetDescription() string

func (*CreateProposalMsg) GetElectionRuleID added in v0.16.0

func (m *CreateProposalMsg) GetElectionRuleID() []byte

func (*CreateProposalMsg) GetMetadata added in v0.16.0

func (m *CreateProposalMsg) GetMetadata() *weave.Metadata

func (*CreateProposalMsg) GetRawOption added in v0.16.0

func (m *CreateProposalMsg) GetRawOption() []byte

func (*CreateProposalMsg) GetStartTime added in v0.16.0

func (*CreateProposalMsg) GetTitle added in v0.16.0

func (m *CreateProposalMsg) GetTitle() string

func (*CreateProposalMsg) Marshal added in v0.16.0

func (m *CreateProposalMsg) Marshal() (dAtA []byte, err error)

func (*CreateProposalMsg) MarshalTo added in v0.16.0

func (m *CreateProposalMsg) MarshalTo(dAtA []byte) (int, error)

func (CreateProposalMsg) Path added in v0.16.0

func (CreateProposalMsg) Path() string

func (*CreateProposalMsg) ProtoMessage added in v0.16.0

func (*CreateProposalMsg) ProtoMessage()

func (*CreateProposalMsg) Reset added in v0.16.0

func (m *CreateProposalMsg) Reset()

func (*CreateProposalMsg) Size added in v0.16.0

func (m *CreateProposalMsg) Size() (n int)

func (*CreateProposalMsg) String added in v0.16.0

func (m *CreateProposalMsg) String() string

func (*CreateProposalMsg) Unmarshal added in v0.16.0

func (m *CreateProposalMsg) Unmarshal(dAtA []byte) error

func (CreateProposalMsg) Validate added in v0.16.0

func (m CreateProposalMsg) Validate() error

func (*CreateProposalMsg) XXX_DiscardUnknown added in v0.16.0

func (m *CreateProposalMsg) XXX_DiscardUnknown()

func (*CreateProposalMsg) XXX_Marshal added in v0.16.0

func (m *CreateProposalMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateProposalMsg) XXX_Merge added in v0.16.0

func (m *CreateProposalMsg) XXX_Merge(src proto.Message)

func (*CreateProposalMsg) XXX_Size added in v0.16.0

func (m *CreateProposalMsg) XXX_Size() int

func (*CreateProposalMsg) XXX_Unmarshal added in v0.16.0

func (m *CreateProposalMsg) XXX_Unmarshal(b []byte) error

type CreateTextResolutionMsg added in v0.17.0

type CreateTextResolutionMsg struct {
	Metadata   *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	Resolution string          `protobuf:"bytes,2,opt,name=resolution,proto3" json:"resolution,omitempty"`
}

TextResolutionMsg is only intended to be dispatched internally from election results. It adds a resolution to the list of "approved" resolutions, with a reference to the electorate that approved it

func (*CreateTextResolutionMsg) Descriptor added in v0.17.0

func (*CreateTextResolutionMsg) Descriptor() ([]byte, []int)

func (*CreateTextResolutionMsg) GetMetadata added in v0.17.0

func (m *CreateTextResolutionMsg) GetMetadata() *weave.Metadata

func (*CreateTextResolutionMsg) GetResolution added in v0.17.0

func (m *CreateTextResolutionMsg) GetResolution() string

func (*CreateTextResolutionMsg) Marshal added in v0.17.0

func (m *CreateTextResolutionMsg) Marshal() (dAtA []byte, err error)

func (*CreateTextResolutionMsg) MarshalTo added in v0.17.0

func (m *CreateTextResolutionMsg) MarshalTo(dAtA []byte) (int, error)

func (CreateTextResolutionMsg) Path added in v0.17.0

func (*CreateTextResolutionMsg) ProtoMessage added in v0.17.0

func (*CreateTextResolutionMsg) ProtoMessage()

func (*CreateTextResolutionMsg) Reset added in v0.17.0

func (m *CreateTextResolutionMsg) Reset()

func (*CreateTextResolutionMsg) Size added in v0.17.0

func (m *CreateTextResolutionMsg) Size() (n int)

func (*CreateTextResolutionMsg) String added in v0.17.0

func (m *CreateTextResolutionMsg) String() string

func (*CreateTextResolutionMsg) Unmarshal added in v0.17.0

func (m *CreateTextResolutionMsg) Unmarshal(dAtA []byte) error

func (CreateTextResolutionMsg) Validate added in v0.17.0

func (m CreateTextResolutionMsg) Validate() error

func (*CreateTextResolutionMsg) XXX_DiscardUnknown added in v0.17.0

func (m *CreateTextResolutionMsg) XXX_DiscardUnknown()

func (*CreateTextResolutionMsg) XXX_Marshal added in v0.17.0

func (m *CreateTextResolutionMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CreateTextResolutionMsg) XXX_Merge added in v0.17.0

func (m *CreateTextResolutionMsg) XXX_Merge(src proto.Message)

func (*CreateTextResolutionMsg) XXX_Size added in v0.17.0

func (m *CreateTextResolutionMsg) XXX_Size() int

func (*CreateTextResolutionMsg) XXX_Unmarshal added in v0.17.0

func (m *CreateTextResolutionMsg) XXX_Unmarshal(b []byte) error

type DeleteProposalHandler added in v0.16.0

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

func (DeleteProposalHandler) Check added in v0.16.0

func (DeleteProposalHandler) Deliver added in v0.16.0

type DeleteProposalMsg added in v0.15.0

type DeleteProposalMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// ProposalID is the unique identifier of the proposal to delete
	ProposalID []byte `protobuf:"bytes,2,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
}

DeleteProposalMsg deletes a governance proposal.

func (*DeleteProposalMsg) Descriptor added in v0.15.0

func (*DeleteProposalMsg) Descriptor() ([]byte, []int)

func (*DeleteProposalMsg) GetMetadata added in v0.15.0

func (m *DeleteProposalMsg) GetMetadata() *weave.Metadata

func (*DeleteProposalMsg) GetProposalID added in v0.16.0

func (m *DeleteProposalMsg) GetProposalID() []byte

func (*DeleteProposalMsg) Marshal added in v0.15.0

func (m *DeleteProposalMsg) Marshal() (dAtA []byte, err error)

func (*DeleteProposalMsg) MarshalTo added in v0.15.0

func (m *DeleteProposalMsg) MarshalTo(dAtA []byte) (int, error)

func (DeleteProposalMsg) Path added in v0.15.0

func (DeleteProposalMsg) Path() string

func (*DeleteProposalMsg) ProtoMessage added in v0.15.0

func (*DeleteProposalMsg) ProtoMessage()

func (*DeleteProposalMsg) Reset added in v0.15.0

func (m *DeleteProposalMsg) Reset()

func (*DeleteProposalMsg) Size added in v0.15.0

func (m *DeleteProposalMsg) Size() (n int)

func (*DeleteProposalMsg) String added in v0.15.0

func (m *DeleteProposalMsg) String() string

func (*DeleteProposalMsg) Unmarshal added in v0.15.0

func (m *DeleteProposalMsg) Unmarshal(dAtA []byte) error

func (DeleteProposalMsg) Validate added in v0.15.0

func (m DeleteProposalMsg) Validate() error

func (*DeleteProposalMsg) XXX_DiscardUnknown added in v0.15.0

func (m *DeleteProposalMsg) XXX_DiscardUnknown()

func (*DeleteProposalMsg) XXX_Marshal added in v0.15.0

func (m *DeleteProposalMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DeleteProposalMsg) XXX_Merge added in v0.15.0

func (m *DeleteProposalMsg) XXX_Merge(src proto.Message)

func (*DeleteProposalMsg) XXX_Size added in v0.15.0

func (m *DeleteProposalMsg) XXX_Size() int

func (*DeleteProposalMsg) XXX_Unmarshal added in v0.15.0

func (m *DeleteProposalMsg) XXX_Unmarshal(b []byte) error

type ElectionRule

type ElectionRule struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Document version.
	Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
	// Admin is the address that is allowed to modify an existing election rule.
	Admin github_com_iov_one_weave.Address `protobuf:"bytes,3,opt,name=admin,proto3,casttype=github.com/iov-one/weave.Address" json:"admin,omitempty"`
	// ElectorateID references the electorate using this rule (without version, as changing electorate changes the rule).
	ElectorateID []byte `protobuf:"bytes,4,opt,name=electorate_id,json=electorateId,proto3" json:"electorate_id,omitempty"`
	// Human readable title.
	Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"`
	// Duration in seconds of how long the voting period will take place.
	VotingPeriod github_com_iov_one_weave.UnixDuration `` /* 145-byte string literal not displayed */
	// Threshold is the fraction of either all eligible voters or in case of a quorum setup the fraction of all non
	// abstained votes.
	// To accept a proposal this value must be exceeded with Yes votes.
	// The formula applied is:
	// (yes * denominator) > (base * numerator) with base total electorate weight or Yes/No votes in case of quorum set
	//
	// 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,7,opt,name=threshold,proto3" json:"threshold"`
	// The quorum fraction of eligible voters is based on the total electorate weight and defines a threshold of
	// votes that must be exceeded before the acceptance threshold is applied.
	// This value requires any kind of votes and not only YES.
	//
	// 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.
	Quorum *Fraction `protobuf:"bytes,8,opt,name=quorum,proto3" json:"quorum,omitempty"`
	// Address of this entity. Set during creation and does not change.
	Address github_com_iov_one_weave.Address `protobuf:"bytes,9,opt,name=address,proto3,casttype=github.com/iov-one/weave.Address" json:"address,omitempty"`
}

Election Rule defines how an election is run. A proposal must be voted upon via a pre-defined ruleset.

func (*ElectionRule) Descriptor

func (*ElectionRule) Descriptor() ([]byte, []int)

func (*ElectionRule) GetAddress added in v0.19.0

func (*ElectionRule) GetAdmin added in v0.15.0

func (*ElectionRule) GetElectorateID added in v0.16.0

func (m *ElectionRule) GetElectorateID() []byte

func (*ElectionRule) GetMetadata added in v0.15.0

func (m *ElectionRule) GetMetadata() *weave.Metadata

func (*ElectionRule) GetQuorum added in v0.15.0

func (m *ElectionRule) GetQuorum() *Fraction

func (*ElectionRule) GetThreshold

func (m *ElectionRule) GetThreshold() Fraction

func (*ElectionRule) GetTitle

func (m *ElectionRule) GetTitle() string

func (*ElectionRule) GetVersion added in v0.15.0

func (m *ElectionRule) GetVersion() uint32

func (*ElectionRule) GetVotingPeriod added in v0.16.0

func (m *ElectionRule) GetVotingPeriod() github_com_iov_one_weave.UnixDuration

func (*ElectionRule) Marshal

func (m *ElectionRule) Marshal() (dAtA []byte, err error)

func (*ElectionRule) MarshalTo

func (m *ElectionRule) MarshalTo(dAtA []byte) (int, error)

func (*ElectionRule) ProtoMessage

func (*ElectionRule) ProtoMessage()

func (*ElectionRule) Reset

func (m *ElectionRule) Reset()

func (*ElectionRule) SetVersion added in v0.15.0

func (m *ElectionRule) SetVersion(v uint32)

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

type ElectionRulesBucket struct {
	orm.VersioningBucket
}

ElectionRulesBucket is the persistent bucket for ElectionRules .

func NewElectionRulesBucket

func NewElectionRulesBucket() *ElectionRulesBucket

NewElectionRulesBucket returns a bucket for managing election rules.

func (*ElectionRulesBucket) NextID added in v0.19.0

func (b *ElectionRulesBucket) NextID(db weave.KVStore) ([]byte, error)

type Elector

type Elector struct {
	// The address of the voter.
	Address github_com_iov_one_weave.Address `protobuf:"bytes,1,opt,name=address,proto3,casttype=github.com/iov-one/weave.Address" json:"address,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 address with a weight. The greater the weight the greater the power of a participant.

func (*Elector) Descriptor

func (*Elector) Descriptor() ([]byte, []int)

func (*Elector) GetAddress added in v0.15.0

func (m *Elector) GetAddress() github_com_iov_one_weave.Address

func (*Elector) GetWeight

func (m *Elector) GetWeight() uint32

func (*Elector) Marshal

func (m *Elector) Marshal() (dAtA []byte, err error)

func (*Elector) MarshalTo

func (m *Elector) MarshalTo(dAtA []byte) (int, error)

func (*Elector) ProtoMessage

func (*Elector) ProtoMessage()

func (*Elector) Reset

func (m *Elector) Reset()

func (*Elector) Size

func (m *Elector) Size() (n int)

func (*Elector) String

func (m *Elector) String() string

func (*Elector) Unmarshal

func (m *Elector) Unmarshal(dAtA []byte) error

func (Elector) Validate

func (m Elector) Validate() error

func (*Elector) XXX_DiscardUnknown

func (m *Elector) XXX_DiscardUnknown()

func (*Elector) XXX_Marshal

func (m *Elector) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Elector) XXX_Merge

func (m *Elector) XXX_Merge(src proto.Message)

func (*Elector) XXX_Size

func (m *Elector) XXX_Size() int

func (*Elector) XXX_Unmarshal

func (m *Elector) XXX_Unmarshal(b []byte) error

type Electorate

type Electorate struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Document version
	Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
	// Admin is the address that is allowed ot modify an existing electorate.
	Admin github_com_iov_one_weave.Address `protobuf:"bytes,3,opt,name=admin,proto3,casttype=github.com/iov-one/weave.Address" json:"admin,omitempty"`
	// Human readable title.
	Title string `protobuf:"bytes,4,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,5,rep,name=electors,proto3" json:"electors"`
	// TotalElectorateWeight is the sum of all electors weights.
	TotalElectorateWeight uint64 `` /* 127-byte string literal not displayed */
}

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) 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) GetAdmin added in v0.15.0

func (*Electorate) GetElectors

func (m *Electorate) GetElectors() []Elector

func (*Electorate) GetMetadata added in v0.15.0

func (m *Electorate) GetMetadata() *weave.Metadata

func (*Electorate) GetTitle

func (m *Electorate) GetTitle() string

func (*Electorate) GetTotalElectorateWeight added in v0.15.0

func (m *Electorate) GetTotalElectorateWeight() uint64

func (*Electorate) GetVersion added in v0.15.0

func (m *Electorate) GetVersion() uint32

func (*Electorate) Marshal

func (m *Electorate) Marshal() (dAtA []byte, err error)

func (*Electorate) MarshalTo

func (m *Electorate) MarshalTo(dAtA []byte) (int, error)

func (*Electorate) ProtoMessage

func (*Electorate) ProtoMessage()

func (*Electorate) Reset

func (m *Electorate) Reset()

func (*Electorate) SetVersion added in v0.15.0

func (m *Electorate) SetVersion(v uint32)

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

type ElectorateBucket struct {
	orm.VersioningBucket
}

ElectorateBucket is the persistent bucket for Electorate object.

func NewElectorateBucket

func NewElectorateBucket() *ElectorateBucket

NewElectorateBucket returns a bucket for managing electorate.

type Executor added in v0.16.0

type Executor func(ctx weave.Context, store weave.KVStore, msg weave.Msg) (*weave.DeliverResult, error)

Executor will do something with the message once it is approved.

func HandlerAsExecutor added in v0.16.0

func HandlerAsExecutor(h weave.Handler) Executor

HandlerAsExecutor wraps the msg in a fake Tx to satisfy the Handler interface Since a Router and Decorators also expose this interface, we can wrap any stack that does not care about the extra Tx info besides Msg.

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) Descriptor() ([]byte, []int)

func (*Fraction) GetDenominator

func (m *Fraction) GetDenominator() uint32

func (*Fraction) GetNumerator

func (m *Fraction) GetNumerator() uint32

func (*Fraction) Marshal

func (m *Fraction) Marshal() (dAtA []byte, err error)

func (*Fraction) MarshalTo

func (m *Fraction) MarshalTo(dAtA []byte) (int, error)

func (*Fraction) ProtoMessage

func (*Fraction) ProtoMessage()

func (*Fraction) Reset

func (m *Fraction) Reset()

func (*Fraction) Size

func (m *Fraction) Size() (n int)

func (*Fraction) String

func (m *Fraction) String() string

func (*Fraction) Unmarshal

func (m *Fraction) Unmarshal(dAtA []byte) error

func (Fraction) Validate

func (m Fraction) Validate() error

func (*Fraction) XXX_DiscardUnknown

func (m *Fraction) XXX_DiscardUnknown()

func (*Fraction) XXX_Marshal

func (m *Fraction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Fraction) XXX_Merge

func (m *Fraction) XXX_Merge(src proto.Message)

func (*Fraction) XXX_Size

func (m *Fraction) XXX_Size() int

func (*Fraction) XXX_Unmarshal

func (m *Fraction) XXX_Unmarshal(b []byte) error

type Initializer

type Initializer struct{}

Initializer fulfils the Initializer interface to load data from the genesis file.

func (*Initializer) FromGenesis

func (*Initializer) FromGenesis(opts weave.Options, params weave.GenesisParams, kv weave.KVStore) error

FromGenesis will parse initial governance electorate and election rules from genesis and saves it in the database.

type OptionDecoder added in v0.16.0

type OptionDecoder func(raw []byte) (weave.Msg, error)

OptionDecoder is needed to parse the raw_options data.

type Proposal added in v0.15.0

type Proposal struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Human readable title.
	Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
	// Content of the proposal. Protobuf encoded, app-specific decoded must be passed in constructor
	RawOption []byte `protobuf:"bytes,3,opt,name=raw_option,json=rawOption,proto3" json:"raw_option,omitempty"`
	// Description of the proposal in text form.
	Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
	// ElectionRuleRef is a reference to the election rule
	ElectionRuleRef orm.VersionedIDRef `protobuf:"bytes,5,opt,name=election_rule_ref,json=electionRuleRef,proto3" json:"election_rule_ref"`
	// Reference to the electorate to define the group of possible voters.
	ElectorateRef orm.VersionedIDRef `protobuf:"bytes,6,opt,name=electorate_ref,json=electorateRef,proto3" json:"electorate_ref"`
	// 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,10,opt,name=author,proto3,casttype=github.com/iov-one/weave.Address" json:"author,omitempty"`
	// Result of the election. Contains intermediate tally results while voting period is open.
	VoteState TallyResult `protobuf:"bytes,11,opt,name=vote_state,json=voteState,proto3" json:"vote_state"`
	// Status represents the high level position in the life cycle of the proposal. Initial value is Submitted.
	Status Proposal_Status `protobuf:"varint,12,opt,name=status,proto3,enum=gov.Proposal_Status" json:"status,omitempty"`
	// Result is the final result based on the votes and election rule. Initial value is Undefined.
	Result Proposal_Result `protobuf:"varint,13,opt,name=result,proto3,enum=gov.Proposal_Result" json:"result,omitempty"`
	// Result is the final result based on the votes and election rule. Initial value is NotRun.
	ExecutorResult Proposal_ExecutorResult `` /* 138-byte string literal not displayed */
	// Tally task ID holds the ID of the asynchronous task that is scheduled to
	// create the tally once the voting period is over.
	TallyTaskID []byte `protobuf:"bytes,15,opt,name=tally_task_id,json=tallyTaskId,proto3" json:"tally_task_id,omitempty"`
}

A generic proposal for an on-chain governance process. Most fields control the whole election process. raw_option contains an transaction to be executed by the governance vote in case of success (what is being voted on)

func CtxProposal added in v0.16.0

func CtxProposal(ctx weave.Context) (*Proposal, []byte)

CtxProposal reads the the proposal and it's id from the context

func (*Proposal) CountVote added in v0.15.0

func (m *Proposal) CountVote(vote Vote) error

CountVote updates the intermediate tally result by adding the new vote weight.

func (*Proposal) Descriptor added in v0.15.0

func (*Proposal) Descriptor() ([]byte, []int)

func (*Proposal) GetAuthor added in v0.15.0

func (m *Proposal) GetAuthor() github_com_iov_one_weave.Address

func (*Proposal) GetDescription added in v0.15.0

func (m *Proposal) GetDescription() string

func (*Proposal) GetElectionRuleRef added in v0.15.0

func (m *Proposal) GetElectionRuleRef() orm.VersionedIDRef

func (*Proposal) GetElectorateRef added in v0.15.0

func (m *Proposal) GetElectorateRef() orm.VersionedIDRef

func (*Proposal) GetExecutorResult added in v0.16.0

func (m *Proposal) GetExecutorResult() Proposal_ExecutorResult

func (*Proposal) GetMetadata added in v0.15.0

func (m *Proposal) GetMetadata() *weave.Metadata

func (*Proposal) GetRawOption added in v0.16.0

func (m *Proposal) GetRawOption() []byte

func (*Proposal) GetResult added in v0.15.0

func (m *Proposal) GetResult() Proposal_Result

func (*Proposal) GetStatus added in v0.15.0

func (m *Proposal) GetStatus() Proposal_Status

func (*Proposal) GetSubmissionTime added in v0.15.0

func (m *Proposal) GetSubmissionTime() github_com_iov_one_weave.UnixTime

func (*Proposal) GetTallyTaskID added in v0.19.0

func (m *Proposal) GetTallyTaskID() []byte

func (*Proposal) GetTitle added in v0.15.0

func (m *Proposal) GetTitle() string

func (*Proposal) GetVoteState added in v0.15.0

func (m *Proposal) GetVoteState() TallyResult

func (*Proposal) GetVotingEndTime added in v0.15.0

func (m *Proposal) GetVotingEndTime() github_com_iov_one_weave.UnixTime

func (*Proposal) GetVotingStartTime added in v0.15.0

func (m *Proposal) GetVotingStartTime() github_com_iov_one_weave.UnixTime

func (*Proposal) Marshal added in v0.15.0

func (m *Proposal) Marshal() (dAtA []byte, err error)

func (*Proposal) MarshalTo added in v0.15.0

func (m *Proposal) MarshalTo(dAtA []byte) (int, error)

func (*Proposal) ProtoMessage added in v0.15.0

func (*Proposal) ProtoMessage()

func (*Proposal) Reset added in v0.15.0

func (m *Proposal) Reset()

func (*Proposal) Size added in v0.15.0

func (m *Proposal) Size() (n int)

func (*Proposal) String added in v0.15.0

func (m *Proposal) String() string

func (*Proposal) Tally added in v0.15.0

func (m *Proposal) Tally() error

Tally calls the final calculation on the votes and sets the status of the proposal according to the election rules threshold.

func (*Proposal) UndoCountVote added in v0.15.0

func (m *Proposal) UndoCountVote(vote Vote) error

UndoCountVote updates the intermediate tally result by subtracting the given vote weight.

func (*Proposal) Unmarshal added in v0.15.0

func (m *Proposal) Unmarshal(dAtA []byte) error

func (*Proposal) Validate added in v0.15.0

func (m *Proposal) Validate() error

func (*Proposal) XXX_DiscardUnknown added in v0.15.0

func (m *Proposal) XXX_DiscardUnknown()

func (*Proposal) XXX_Marshal added in v0.15.0

func (m *Proposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Proposal) XXX_Merge added in v0.15.0

func (m *Proposal) XXX_Merge(src proto.Message)

func (*Proposal) XXX_Size added in v0.15.0

func (m *Proposal) XXX_Size() int

func (*Proposal) XXX_Unmarshal added in v0.15.0

func (m *Proposal) XXX_Unmarshal(b []byte) error

type ProposalBucket

type ProposalBucket struct {
	orm.IDGenBucket
}

ProposalBucket is the persistent bucket for governance proposal objects.

func NewProposalBucket

func NewProposalBucket() *ProposalBucket

NewProposalBucket returns a bucket for managing electorate.

func (*ProposalBucket) GetProposal added in v0.15.0

func (b *ProposalBucket) GetProposal(db weave.KVStore, id []byte) (*Proposal, error)

GetProposal loads the proposal 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 *Proposal) error

Update stores the given proposal and id in the persistence store.

type Proposal_ExecutorResult added in v0.16.0

type Proposal_ExecutorResult int32
const (
	// An empty value is not allowed
	Proposal_PROPOSAL_EXECUTOR_RESULT_INVALID Proposal_ExecutorResult = 0
	// We have not yet run the executor
	Proposal_NotRun Proposal_ExecutorResult = 1
	// The executor was successful and proposed action updated state
	Proposal_Success Proposal_ExecutorResult = 2
	// The executor returned an error and proposed action didn't update state
	Proposal_Failure Proposal_ExecutorResult = 3
)

func (Proposal_ExecutorResult) EnumDescriptor added in v0.16.0

func (Proposal_ExecutorResult) EnumDescriptor() ([]byte, []int)

func (Proposal_ExecutorResult) String added in v0.16.0

func (x Proposal_ExecutorResult) String() string

type Proposal_Result added in v0.15.0

type Proposal_Result int32
const (
	// An empty value is invalid and not allowed
	Proposal_PROPOSAL_RESULT_INVALID Proposal_Result = 0
	// Until a final tally has happened the status is undefined
	Proposal_Undefined Proposal_Result = 1
	// Final result of the tally
	Proposal_Accepted Proposal_Result = 2
	// Final result of the tally
	Proposal_Rejected Proposal_Result = 3
)

func (Proposal_Result) EnumDescriptor added in v0.15.0

func (Proposal_Result) EnumDescriptor() ([]byte, []int)

func (Proposal_Result) String added in v0.15.0

func (x Proposal_Result) String() string

type Proposal_Status added in v0.15.0

type Proposal_Status int32
const (
	// An empty value is invalid and not allowed
	Proposal_PROPOSAL_STATUS_INVALID Proposal_Status = 0
	// Initial status of a proposal when persisted.
	Proposal_Submitted Proposal_Status = 1
	// Final status of a proposal when the tally was executed
	Proposal_Closed Proposal_Status = 2
	// A proposal can be deleted before the voting start time by the owner. When this happens the final status
	// is Withdrawn.
	Proposal_Withdrawn Proposal_Status = 3
)

func (Proposal_Status) EnumDescriptor added in v0.15.0

func (Proposal_Status) EnumDescriptor() ([]byte, []int)

func (Proposal_Status) String added in v0.15.0

func (x Proposal_Status) String() string

type Resolution added in v0.16.0

type Resolution struct {
	Metadata      *weave.Metadata    `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	ProposalID    []byte             `protobuf:"bytes,2,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
	ElectorateRef orm.VersionedIDRef `protobuf:"bytes,3,opt,name=electorate_ref,json=electorateRef,proto3" json:"electorate_ref"`
	Resolution    string             `protobuf:"bytes,4,opt,name=resolution,proto3" json:"resolution,omitempty"`
}

Resolution contains TextResolution and an electorate reference.

func (*Resolution) Descriptor added in v0.16.0

func (*Resolution) Descriptor() ([]byte, []int)

func (*Resolution) GetElectorateRef added in v0.16.0

func (m *Resolution) GetElectorateRef() orm.VersionedIDRef

func (*Resolution) GetMetadata added in v0.16.0

func (m *Resolution) GetMetadata() *weave.Metadata

func (*Resolution) GetProposalID added in v0.16.0

func (m *Resolution) GetProposalID() []byte

func (*Resolution) GetResolution added in v0.16.0

func (m *Resolution) GetResolution() string

func (*Resolution) Marshal added in v0.16.0

func (m *Resolution) Marshal() (dAtA []byte, err error)

func (*Resolution) MarshalTo added in v0.16.0

func (m *Resolution) MarshalTo(dAtA []byte) (int, error)

func (*Resolution) ProtoMessage added in v0.16.0

func (*Resolution) ProtoMessage()

func (*Resolution) Reset added in v0.16.0

func (m *Resolution) Reset()

func (*Resolution) Size added in v0.16.0

func (m *Resolution) Size() (n int)

func (*Resolution) String added in v0.16.0

func (m *Resolution) String() string

func (*Resolution) Unmarshal added in v0.16.0

func (m *Resolution) Unmarshal(dAtA []byte) error

func (*Resolution) Validate added in v0.16.0

func (r *Resolution) Validate() error

func (*Resolution) XXX_DiscardUnknown added in v0.16.0

func (m *Resolution) XXX_DiscardUnknown()

func (*Resolution) XXX_Marshal added in v0.16.0

func (m *Resolution) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Resolution) XXX_Merge added in v0.16.0

func (m *Resolution) XXX_Merge(src proto.Message)

func (*Resolution) XXX_Size added in v0.16.0

func (m *Resolution) XXX_Size() int

func (*Resolution) XXX_Unmarshal added in v0.16.0

func (m *Resolution) XXX_Unmarshal(b []byte) error

type ResolutionBucket added in v0.16.0

type ResolutionBucket struct {
	orm.IDGenBucket
}

ResolutionBucket is the persistence bucket for resolutions.

func NewResolutionBucket added in v0.16.0

func NewResolutionBucket() *ResolutionBucket

func (*ResolutionBucket) GetResolution added in v0.16.0

func (b *ResolutionBucket) GetResolution(db weave.KVStore, id []byte) (*Resolution, error)

GetResolution loads the resolution for the given id. If it does not exist then ErrNotFound is returned.

type TallyHandler

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

func (TallyHandler) Check

func (h TallyHandler) Check(ctx weave.Context, db weave.KVStore, tx weave.Tx) (*weave.CheckResult, error)

func (TallyHandler) Deliver

func (h TallyHandler) Deliver(ctx weave.Context, db weave.KVStore, tx weave.Tx) (resOut *weave.DeliverResult, errOut error)

type TallyMsg

type TallyMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// ProposalID is UUID of the proposal to close.
	ProposalID []byte `protobuf:"bytes,2,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) Descriptor() ([]byte, []int)

func (*TallyMsg) GetMetadata added in v0.15.0

func (m *TallyMsg) GetMetadata() *weave.Metadata

func (*TallyMsg) GetProposalID

func (m *TallyMsg) GetProposalID() []byte

func (*TallyMsg) Marshal

func (m *TallyMsg) Marshal() (dAtA []byte, err error)

func (*TallyMsg) MarshalTo

func (m *TallyMsg) MarshalTo(dAtA []byte) (int, error)

func (TallyMsg) Path

func (TallyMsg) Path() string

func (*TallyMsg) ProtoMessage

func (*TallyMsg) ProtoMessage()

func (*TallyMsg) Reset

func (m *TallyMsg) Reset()

func (*TallyMsg) Size

func (m *TallyMsg) Size() (n int)

func (*TallyMsg) String

func (m *TallyMsg) String() string

func (*TallyMsg) Unmarshal

func (m *TallyMsg) Unmarshal(dAtA []byte) error

func (TallyMsg) Validate

func (m TallyMsg) Validate() error

func (*TallyMsg) XXX_DiscardUnknown

func (m *TallyMsg) XXX_DiscardUnknown()

func (*TallyMsg) XXX_Marshal

func (m *TallyMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TallyMsg) XXX_Merge

func (m *TallyMsg) XXX_Merge(src proto.Message)

func (*TallyMsg) XXX_Size

func (m *TallyMsg) XXX_Size() int

func (*TallyMsg) XXX_Unmarshal

func (m *TallyMsg) XXX_Unmarshal(b []byte) error

type TallyResult

type TallyResult struct {
	// TotalYes is the sum of weights of all the voters that approved the proposal
	TotalYes uint64 `protobuf:"varint,1,opt,name=total_yes,json=totalYes,proto3" json:"total_yes,omitempty"`
	// TotalNo is the sum of weights of all the voters that rejected the proposal
	TotalNo uint64 `protobuf:"varint,2,opt,name=total_no,json=totalNo,proto3" json:"total_no,omitempty"`
	// TotalAbstain is the sum of weights of all the voters that voted abstain
	TotalAbstain uint64 `protobuf:"varint,3,opt,name=total_abstain,json=totalAbstain,proto3" json:"total_abstain,omitempty"`
	// TotalElectorateWeight is the sum of all weights in the electorate.
	TotalElectorateWeight uint64 `` /* 127-byte string literal not displayed */
	// Quorum when set is the fraction of the total electorate weight that must be exceeded by total votes weight.
	Quorum *Fraction `protobuf:"bytes,5,opt,name=quorum,proto3" json:"quorum,omitempty"`
	// Threshold is the fraction of Yes votes of a base value that needs to be exceeded to accept the proposal.
	// The base value is either the total electorate weight or the sum of Yes/No weights when a quorum is defined.
	Threshold Fraction `protobuf:"bytes,6,opt,name=threshold,proto3" json:"threshold"`
}

TallyResult contains sums of the votes and all data for the final result.

func NewTallyResult added in v0.15.0

func NewTallyResult(quorum *Fraction, threshold Fraction, totalElectorateWeight uint64) TallyResult

func (TallyResult) Accepted

func (m TallyResult) Accepted() bool

Accepted returns the result of the calculation if a proposal got enough votes or not.

func (*TallyResult) Descriptor

func (*TallyResult) Descriptor() ([]byte, []int)

func (*TallyResult) GetQuorum added in v0.15.0

func (m *TallyResult) GetQuorum() *Fraction

func (*TallyResult) GetThreshold

func (m *TallyResult) GetThreshold() Fraction

func (*TallyResult) GetTotalAbstain

func (m *TallyResult) GetTotalAbstain() uint64

func (*TallyResult) GetTotalElectorateWeight added in v0.15.0

func (m *TallyResult) GetTotalElectorateWeight() uint64

func (*TallyResult) GetTotalNo

func (m *TallyResult) GetTotalNo() uint64

func (*TallyResult) GetTotalYes

func (m *TallyResult) GetTotalYes() uint64

func (*TallyResult) Marshal

func (m *TallyResult) Marshal() (dAtA []byte, err error)

func (*TallyResult) MarshalTo

func (m *TallyResult) MarshalTo(dAtA []byte) (int, 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) TotalVotes added in v0.15.0

func (m TallyResult) TotalVotes() uint64

TotalVotes returns the sum of yes, no, abstain votes weights.

func (*TallyResult) Unmarshal

func (m *TallyResult) Unmarshal(dAtA []byte) error

func (TallyResult) Validate added in v0.15.0

func (m TallyResult) Validate() 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 UpdateElectionRuleHandler added in v0.15.0

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

func (UpdateElectionRuleHandler) Check added in v0.15.0

func (UpdateElectionRuleHandler) Deliver added in v0.15.0

type UpdateElectionRuleMsg added in v0.15.0

type UpdateElectionRuleMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// ElectionRuleID is a reference to the election rule
	ElectionRuleID []byte `protobuf:"bytes,2,opt,name=election_rule_id,json=electionRuleId,proto3" json:"election_rule_id,omitempty"`
	// Duration in seconds of how long the voting period will take place.
	VotingPeriod github_com_iov_one_weave.UnixDuration `` /* 145-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.
	// 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"`
	// The quorum fraction of eligible voters is based on the total electorate
	// weight and defines a threshold of votes that must be exceeded before the
	// acceptance threshold is applied. This value requires any kind of votes
	// and not only YES.
	//
	// 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.
	Quorum *Fraction `protobuf:"bytes,5,opt,name=quorum,proto3" json:"quorum,omitempty"`
}

func (*UpdateElectionRuleMsg) Descriptor added in v0.15.0

func (*UpdateElectionRuleMsg) Descriptor() ([]byte, []int)

func (*UpdateElectionRuleMsg) GetElectionRuleID added in v0.15.0

func (m *UpdateElectionRuleMsg) GetElectionRuleID() []byte

func (*UpdateElectionRuleMsg) GetMetadata added in v0.15.0

func (m *UpdateElectionRuleMsg) GetMetadata() *weave.Metadata

func (*UpdateElectionRuleMsg) GetQuorum added in v0.19.0

func (m *UpdateElectionRuleMsg) GetQuorum() *Fraction

func (*UpdateElectionRuleMsg) GetThreshold added in v0.15.0

func (m *UpdateElectionRuleMsg) GetThreshold() Fraction

func (*UpdateElectionRuleMsg) GetVotingPeriod added in v0.16.0

func (*UpdateElectionRuleMsg) Marshal added in v0.15.0

func (m *UpdateElectionRuleMsg) Marshal() (dAtA []byte, err error)

func (*UpdateElectionRuleMsg) MarshalTo added in v0.15.0

func (m *UpdateElectionRuleMsg) MarshalTo(dAtA []byte) (int, error)

func (UpdateElectionRuleMsg) Path added in v0.15.0

func (*UpdateElectionRuleMsg) ProtoMessage added in v0.15.0

func (*UpdateElectionRuleMsg) ProtoMessage()

func (*UpdateElectionRuleMsg) Reset added in v0.15.0

func (m *UpdateElectionRuleMsg) Reset()

func (*UpdateElectionRuleMsg) Size added in v0.15.0

func (m *UpdateElectionRuleMsg) Size() (n int)

func (*UpdateElectionRuleMsg) String added in v0.15.0

func (m *UpdateElectionRuleMsg) String() string

func (*UpdateElectionRuleMsg) Unmarshal added in v0.15.0

func (m *UpdateElectionRuleMsg) Unmarshal(dAtA []byte) error

func (UpdateElectionRuleMsg) Validate added in v0.15.0

func (m UpdateElectionRuleMsg) Validate() error

func (*UpdateElectionRuleMsg) XXX_DiscardUnknown added in v0.15.0

func (m *UpdateElectionRuleMsg) XXX_DiscardUnknown()

func (*UpdateElectionRuleMsg) XXX_Marshal added in v0.15.0

func (m *UpdateElectionRuleMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateElectionRuleMsg) XXX_Merge added in v0.15.0

func (m *UpdateElectionRuleMsg) XXX_Merge(src proto.Message)

func (*UpdateElectionRuleMsg) XXX_Size added in v0.15.0

func (m *UpdateElectionRuleMsg) XXX_Size() int

func (*UpdateElectionRuleMsg) XXX_Unmarshal added in v0.15.0

func (m *UpdateElectionRuleMsg) XXX_Unmarshal(b []byte) error

type UpdateElectorateHandler added in v0.15.0

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

func (UpdateElectorateHandler) Check added in v0.15.0

func (UpdateElectorateHandler) Deliver added in v0.15.0

type UpdateElectorateMsg added in v0.15.0

type UpdateElectorateMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// ElectorateID is the reference to the electorate that defines the group of possible voters.
	ElectorateID []byte `protobuf:"bytes,2,opt,name=electorate_id,json=electorateId,proto3" json:"electorate_id,omitempty"`
	// DiffElectors contains the changes that should be applied. Adding an address should have a positive weight, removing
	// with weight=0.
	DiffElectors []Elector `protobuf:"bytes,3,rep,name=diff_electors,json=diffElectors,proto3" json:"diff_electors"`
}

func (*UpdateElectorateMsg) Descriptor added in v0.15.0

func (*UpdateElectorateMsg) Descriptor() ([]byte, []int)

func (*UpdateElectorateMsg) GetDiffElectors added in v0.15.0

func (m *UpdateElectorateMsg) GetDiffElectors() []Elector

func (*UpdateElectorateMsg) GetElectorateID added in v0.15.0

func (m *UpdateElectorateMsg) GetElectorateID() []byte

func (*UpdateElectorateMsg) GetMetadata added in v0.15.0

func (m *UpdateElectorateMsg) GetMetadata() *weave.Metadata

func (*UpdateElectorateMsg) Marshal added in v0.15.0

func (m *UpdateElectorateMsg) Marshal() (dAtA []byte, err error)

func (*UpdateElectorateMsg) MarshalTo added in v0.15.0

func (m *UpdateElectorateMsg) MarshalTo(dAtA []byte) (int, error)

func (UpdateElectorateMsg) Path added in v0.15.0

func (UpdateElectorateMsg) Path() string

func (*UpdateElectorateMsg) ProtoMessage added in v0.15.0

func (*UpdateElectorateMsg) ProtoMessage()

func (*UpdateElectorateMsg) Reset added in v0.15.0

func (m *UpdateElectorateMsg) Reset()

func (*UpdateElectorateMsg) Size added in v0.15.0

func (m *UpdateElectorateMsg) Size() (n int)

func (*UpdateElectorateMsg) String added in v0.15.0

func (m *UpdateElectorateMsg) String() string

func (*UpdateElectorateMsg) Unmarshal added in v0.15.0

func (m *UpdateElectorateMsg) Unmarshal(dAtA []byte) error

func (UpdateElectorateMsg) Validate added in v0.15.0

func (m UpdateElectorateMsg) Validate() error

func (*UpdateElectorateMsg) XXX_DiscardUnknown added in v0.15.0

func (m *UpdateElectorateMsg) XXX_DiscardUnknown()

func (*UpdateElectorateMsg) XXX_Marshal added in v0.15.0

func (m *UpdateElectorateMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateElectorateMsg) XXX_Merge added in v0.15.0

func (m *UpdateElectorateMsg) XXX_Merge(src proto.Message)

func (*UpdateElectorateMsg) XXX_Size added in v0.15.0

func (m *UpdateElectorateMsg) XXX_Size() int

func (*UpdateElectorateMsg) XXX_Unmarshal added in v0.15.0

func (m *UpdateElectorateMsg) XXX_Unmarshal(b []byte) error

type Vote

type Vote struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Elector is who voted
	Elector Elector `protobuf:"bytes,2,opt,name=elector,proto3" json:"elector"`
	// VoteOption is what they voted
	Voted VoteOption `protobuf:"varint,3,opt,name=voted,proto3,enum=gov.VoteOption" json:"voted,omitempty"`
}

Vote combines the elector and their voted option to archive them. The proposalID and address is stored within the key.

func (*Vote) Descriptor

func (*Vote) Descriptor() ([]byte, []int)

func (*Vote) GetElector

func (m *Vote) GetElector() Elector

func (*Vote) GetMetadata added in v0.15.0

func (m *Vote) GetMetadata() *weave.Metadata

func (*Vote) GetVoted

func (m *Vote) GetVoted() VoteOption

func (*Vote) Marshal

func (m *Vote) Marshal() (dAtA []byte, err error)

func (*Vote) MarshalTo

func (m *Vote) MarshalTo(dAtA []byte) (int, error)

func (*Vote) ProtoMessage

func (*Vote) ProtoMessage()

func (*Vote) Reset

func (m *Vote) Reset()

func (*Vote) Size

func (m *Vote) Size() (n int)

func (*Vote) String

func (m *Vote) String() string

func (*Vote) Unmarshal

func (m *Vote) Unmarshal(dAtA []byte) error

func (Vote) Validate added in v0.15.0

func (m Vote) Validate() error

validate vote object contains valid elector and voted option

func (*Vote) XXX_DiscardUnknown

func (m *Vote) XXX_DiscardUnknown()

func (*Vote) XXX_Marshal

func (m *Vote) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Vote) XXX_Merge

func (m *Vote) XXX_Merge(src proto.Message)

func (*Vote) XXX_Size

func (m *Vote) XXX_Size() int

func (*Vote) XXX_Unmarshal

func (m *Vote) XXX_Unmarshal(b []byte) error

type VoteBucket added in v0.15.0

type VoteBucket struct {
	orm.Bucket
}

VoteBucket is the persistence bucket for votes.

func NewVoteBucket added in v0.15.0

func NewVoteBucket() *VoteBucket

NewVoteBucket returns a bucket for managing electorate.

func (*VoteBucket) Build added in v0.15.0

func (b *VoteBucket) Build(db weave.KVStore, proposalID []byte, vote Vote) orm.Object

Build creates the orm object without storing it.

func (*VoteBucket) GetVote added in v0.15.0

func (b *VoteBucket) GetVote(db weave.KVStore, proposalID []byte, addr weave.Address) (*Vote, error)

GetVote loads the vote from the archive for the given proposal id and elector address. returns `errors.ErrNotFound` when not exists.

func (*VoteBucket) HasVoted added in v0.15.0

func (b *VoteBucket) HasVoted(db weave.KVStore, proposalID []byte, addr weave.Address) (bool, error)

HasVoted checks the bucket if any vote matching elector address and proposal id was stored.

type VoteHandler

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

func (VoteHandler) Check

func (h VoteHandler) Check(ctx weave.Context, db weave.KVStore, tx weave.Tx) (*weave.CheckResult, error)

func (VoteHandler) Deliver

func (h VoteHandler) Deliver(ctx weave.Context, db weave.KVStore, tx weave.Tx) (*weave.DeliverResult, error)

type VoteMsg

type VoteMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// The unique id of the proposal.
	ProposalID []byte `protobuf:"bytes,2,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"`
	// The address of the voter. The voter address must be part of the electorate
	// in order to be allowed to vote.
	// Warning: This field is optional and when not set it will default to any
	// signer. It is recommended to always explicitely set the value of this
	// field, as the signer order is not guaranteed.
	Voter github_com_iov_one_weave.Address `protobuf:"bytes,3,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,4,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) Descriptor() ([]byte, []int)

func (*VoteMsg) GetMetadata added in v0.15.0

func (m *VoteMsg) GetMetadata() *weave.Metadata

func (*VoteMsg) GetProposalID

func (m *VoteMsg) GetProposalID() []byte

func (*VoteMsg) GetSelected

func (m *VoteMsg) GetSelected() VoteOption

func (*VoteMsg) GetVoter

func (*VoteMsg) Marshal

func (m *VoteMsg) Marshal() (dAtA []byte, err error)

func (*VoteMsg) MarshalTo

func (m *VoteMsg) MarshalTo(dAtA []byte) (int, error)

func (VoteMsg) Path

func (VoteMsg) Path() string

func (*VoteMsg) ProtoMessage

func (*VoteMsg) ProtoMessage()

func (*VoteMsg) Reset

func (m *VoteMsg) Reset()

func (*VoteMsg) Size

func (m *VoteMsg) Size() (n int)

func (*VoteMsg) String

func (m *VoteMsg) String() string

func (*VoteMsg) Unmarshal

func (m *VoteMsg) Unmarshal(dAtA []byte) error

func (VoteMsg) Validate

func (m VoteMsg) Validate() error

func (*VoteMsg) XXX_DiscardUnknown

func (m *VoteMsg) XXX_DiscardUnknown()

func (*VoteMsg) XXX_Marshal

func (m *VoteMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*VoteMsg) XXX_Merge

func (m *VoteMsg) XXX_Merge(src proto.Message)

func (*VoteMsg) XXX_Size

func (m *VoteMsg) XXX_Size() int

func (*VoteMsg) XXX_Unmarshal

func (m *VoteMsg) XXX_Unmarshal(b []byte) error

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

Jump to

Keyboard shortcuts

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