gov

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: Apache-2.0 Imports: 16 Imported by: 7

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_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 Proposal_Type_name = map[int32]string{
	0: "PROPOSAL_TYPE_INVALID",
	1: "PROPOSAL_TYPE_TEXT",
	2: "PROPOSAL_TYPE_UPDATE_ELECTORATE",
}
View Source
var Proposal_Type_value = map[string]int32{
	"PROPOSAL_TYPE_INVALID":           0,
	"PROPOSAL_TYPE_TEXT":              1,
	"PROPOSAL_TYPE_UPDATE_ELECTORATE": 2,
}
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 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 CreateElectorateUpdateProposalMsg added in v0.15.0

type CreateElectorateUpdateProposalMsg 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"`
	// Human readable description with 3 to 5000 chars.
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	// ElectorateID is the reference to the electorate that defines 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,6,opt,name=author,proto3,casttype=github.com/iov-one/weave.Address" json:"author,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,7,rep,name=diff_electors,json=diffElectors,proto3" json:"diff_electors"`
}

CreateElectorateUpdateProposalMsg creates a new governance proposal to update an electorate.

func (*CreateElectorateUpdateProposalMsg) Descriptor added in v0.15.0

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

func (*CreateElectorateUpdateProposalMsg) GetAuthor added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) GetDescription added in v0.15.0

func (m *CreateElectorateUpdateProposalMsg) GetDescription() string

func (*CreateElectorateUpdateProposalMsg) GetDiffElectors added in v0.15.0

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

func (*CreateElectorateUpdateProposalMsg) GetElectorateID added in v0.15.0

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

func (*CreateElectorateUpdateProposalMsg) GetMetadata added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) GetStartTime added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) GetTitle added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) Marshal added in v0.15.0

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

func (*CreateElectorateUpdateProposalMsg) MarshalTo added in v0.15.0

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

func (CreateElectorateUpdateProposalMsg) Path added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) ProtoMessage added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) ProtoMessage()

func (*CreateElectorateUpdateProposalMsg) Reset added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) Size added in v0.15.0

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

func (*CreateElectorateUpdateProposalMsg) String added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) Unmarshal added in v0.15.0

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

func (CreateElectorateUpdateProposalMsg) Validate added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) XXX_DiscardUnknown added in v0.15.0

func (m *CreateElectorateUpdateProposalMsg) XXX_DiscardUnknown()

func (*CreateElectorateUpdateProposalMsg) XXX_Marshal added in v0.15.0

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

func (*CreateElectorateUpdateProposalMsg) XXX_Merge added in v0.15.0

func (*CreateElectorateUpdateProposalMsg) XXX_Size added in v0.15.0

func (m *CreateElectorateUpdateProposalMsg) XXX_Size() int

func (*CreateElectorateUpdateProposalMsg) XXX_Unmarshal added in v0.15.0

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

type CreateTextProposalMsg

type CreateTextProposalMsg 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"`
	// Human readable description with 3 to 5000 chars.
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	// ElectionRuleID is a reference to the election rule
	ElectionRuleID []byte `protobuf:"bytes,4,opt,name=election_rule_id,json=electionRuleId,proto3" json:"election_rule_id,omitempty"`
	// ElectorateID is the reference to the electorate to define the group of possible voters.
	ElectorateID []byte `protobuf:"bytes,5,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,7,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 (*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) GetMetadata added in v0.15.0

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

func (*CreateTextProposalMsg) GetStartTime

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

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

DeleteProposalMsg deletes a governance proposal.

func (*DeleteProposalMsg) Descriptor added in v0.15.0

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

func (*DeleteProposalMsg) GetID added in v0.15.0

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

func (*DeleteProposalMsg) GetMetadata added in v0.15.0

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

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

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

func (DeleteTextProposalHandler) Check added in v0.15.0

func (DeleteTextProposalHandler) Deliver added in v0.15.0

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 ot 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"`
	// Human readable title.
	Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
	// Duration how long the voting period will take place.
	VotingPeriodHours uint32 `protobuf:"varint,5,opt,name=voting_period_hours,json=votingPeriodHours,proto3" json:"voting_period_hours,omitempty"`
	// 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,6,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,7,opt,name=quorum,proto3" json:"quorum,omitempty"`
}

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

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) GetVotingPeriodHours

func (m *ElectionRule) GetVotingPeriodHours() uint32

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
}

NewElectionRulesBucket is the persistent bucket for ElectionRules .

func NewElectionRulesBucket

func NewElectionRulesBucket() *ElectionRulesBucket

NewElectionRulesBucket returns a bucket for managing election rules.

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 */
	// UpdateElectionRuleRef reference the rule to update this electorate.
	UpdateElectionRuleRef orm.VersionedIDRef `protobuf:"bytes,7,opt,name=update_election_rule_ref,json=updateElectionRuleRef,proto3" json:"update_election_rule_ref"`
}

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

func (m *Electorate) GetUpdateElectionRuleRef() orm.VersionedIDRef

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

NewRevenueBucket returns a bucket for managing electorate.

type ElectorateUpdatePayload added in v0.15.0

type ElectorateUpdatePayload struct {
	// DiffElectors contains the changes that should be applied. Adding an address should have a positive weight, removing
	// with weight=0.
	DiffElectors []Elector `protobuf:"bytes,1,rep,name=diff_electors,json=diffElectors,proto3" json:"diff_electors"`
}

func (*ElectorateUpdatePayload) Descriptor added in v0.15.0

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

func (*ElectorateUpdatePayload) GetDiffElectors added in v0.15.0

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

func (*ElectorateUpdatePayload) Marshal added in v0.15.0

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

func (*ElectorateUpdatePayload) MarshalTo added in v0.15.0

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

func (*ElectorateUpdatePayload) ProtoMessage added in v0.15.0

func (*ElectorateUpdatePayload) ProtoMessage()

func (*ElectorateUpdatePayload) Reset added in v0.15.0

func (m *ElectorateUpdatePayload) Reset()

func (*ElectorateUpdatePayload) Size added in v0.15.0

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

func (*ElectorateUpdatePayload) String added in v0.15.0

func (m *ElectorateUpdatePayload) String() string

func (*ElectorateUpdatePayload) Unmarshal added in v0.15.0

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

func (*ElectorateUpdatePayload) Validate added in v0.15.0

func (m *ElectorateUpdatePayload) Validate() error

func (*ElectorateUpdatePayload) XXX_DiscardUnknown added in v0.15.0

func (m *ElectorateUpdatePayload) XXX_DiscardUnknown()

func (*ElectorateUpdatePayload) XXX_Marshal added in v0.15.0

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

func (*ElectorateUpdatePayload) XXX_Merge added in v0.15.0

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

func (*ElectorateUpdatePayload) XXX_Size added in v0.15.0

func (m *ElectorateUpdatePayload) XXX_Size() int

func (*ElectorateUpdatePayload) XXX_Unmarshal added in v0.15.0

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

type ElectorateUpdateProposalHandler added in v0.15.0

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

func (ElectorateUpdateProposalHandler) Check added in v0.15.0

func (ElectorateUpdateProposalHandler) Deliver added in v0.15.0

type ElectorsDiff added in v0.15.0

type ElectorsDiff []Elector

DiffElectors contains the changes that should be applied. Adding an address should have a positive weight, removing with weight=0.

func (ElectorsDiff) Validate added in v0.15.0

func (e ElectorsDiff) Validate() error

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, db weave.KVStore) error

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

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"`
	// Description of the proposal in text form.
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	// ElectionRuleRef is a reference to the election rule
	ElectionRuleRef orm.VersionedIDRef `protobuf:"bytes,4,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,5,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,9,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,10,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,11,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,12,opt,name=result,proto3,enum=gov.Proposal_Result" json:"result,omitempty"`
	Type   Proposal_Type   `protobuf:"varint,13,opt,name=type,proto3,enum=gov.Proposal_Type" json:"type,omitempty"`
	// details
	//
	// Types that are valid to be assigned to Details:
	//	*Proposal_TextDetails
	//	*Proposal_ElectorateUpdateDetails
	Details isProposal_Details `protobuf_oneof:"details"`
}

A generic proposal for an on-chain governance process.

func (Proposal) Copy added in v0.15.0

func (m Proposal) Copy() orm.CloneableData

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

func (m *Proposal) GetDetails() isProposal_Details

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

func (m *Proposal) GetElectorateUpdateDetails() *ElectorateUpdatePayload

func (*Proposal) GetMetadata added in v0.15.0

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

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

func (m *Proposal) GetTextDetails() *TextProposalPayload

func (*Proposal) GetTitle added in v0.15.0

func (m *Proposal) GetTitle() string

func (*Proposal) GetType added in v0.15.0

func (m *Proposal) GetType() Proposal_Type

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

func (*Proposal) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

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

type Proposal_ElectorateUpdateDetails struct {
	ElectorateUpdateDetails *ElectorateUpdatePayload `protobuf:"bytes,51,opt,name=electorate_update_details,json=electorateUpdateDetails,proto3,oneof"`
}

func (*Proposal_ElectorateUpdateDetails) MarshalTo added in v0.15.0

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

func (*Proposal_ElectorateUpdateDetails) Size added in v0.15.0

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

type Proposal_Result added in v0.15.0

type Proposal_Result int32
const (
	// An empty value is invalid and not allowed
	Proposal_Empty 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_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 Proposal_TextDetails added in v0.15.0

type Proposal_TextDetails struct {
	TextDetails *TextProposalPayload `protobuf:"bytes,50,opt,name=text_details,json=textDetails,proto3,oneof"`
}

func (*Proposal_TextDetails) MarshalTo added in v0.15.0

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

func (*Proposal_TextDetails) Size added in v0.15.0

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

type Proposal_Type added in v0.15.0

type Proposal_Type int32
const (
	// None is invalid and not allowed
	Proposal_None Proposal_Type = 0
	// Text
	Proposal_Text Proposal_Type = 1
	// UpdateElectorate
	Proposal_UpdateElectorate Proposal_Type = 2
)

func (Proposal_Type) EnumDescriptor added in v0.15.0

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

func (Proposal_Type) String added in v0.15.0

func (x Proposal_Type) String() string

type TallyHandler

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

func NewTallyHandler added in v0.15.0

func NewTallyHandler(auth x.Authenticator, bucket *ProposalBucket, electBucket *ElectorateBucket) *TallyHandler

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) (*weave.DeliverResult, 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 TallyResultExecutor added in v0.15.0

type TallyResultExecutor func(db weave.KVStore, p *Proposal) error

TallyResultExecutor functionality to be executed on successful proposal.

type TextProposalHandler

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

func (TextProposalHandler) Check

func (TextProposalHandler) Deliver

type TextProposalPayload added in v0.15.0

type TextProposalPayload struct {
}

A text form proposal for an on-chain governance process.

func (*TextProposalPayload) Descriptor added in v0.15.0

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

func (*TextProposalPayload) Marshal added in v0.15.0

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

func (*TextProposalPayload) MarshalTo added in v0.15.0

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

func (*TextProposalPayload) ProtoMessage added in v0.15.0

func (*TextProposalPayload) ProtoMessage()

func (*TextProposalPayload) Reset added in v0.15.0

func (m *TextProposalPayload) Reset()

func (*TextProposalPayload) Size added in v0.15.0

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

func (*TextProposalPayload) String added in v0.15.0

func (m *TextProposalPayload) String() string

func (*TextProposalPayload) Unmarshal added in v0.15.0

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

func (*TextProposalPayload) XXX_DiscardUnknown added in v0.15.0

func (m *TextProposalPayload) XXX_DiscardUnknown()

func (*TextProposalPayload) XXX_Marshal added in v0.15.0

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

func (*TextProposalPayload) XXX_Merge added in v0.15.0

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

func (*TextProposalPayload) XXX_Size added in v0.15.0

func (m *TextProposalPayload) XXX_Size() int

func (*TextProposalPayload) XXX_Unmarshal added in v0.15.0

func (m *TextProposalPayload) 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 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"`
}

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

func (m *UpdateElectionRuleMsg) GetThreshold() Fraction

func (*UpdateElectionRuleMsg) GetVotingPeriodHours added in v0.15.0

func (m *UpdateElectionRuleMsg) GetVotingPeriodHours() uint32

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

func (m Vote) Copy() orm.CloneableData

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"`
	// 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,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