governance

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Proposal Types
	ProposalTypeConfigUpdate ProposalType = 0x20
	ProposalTypeCodeChange   ProposalType = 0x21
	ProposalTypeGeneral      ProposalType = 0x22

	//Proposal Status
	ProposalStatusFunding   ProposalStatus = 0x23
	ProposalStatusVoting    ProposalStatus = 0x24
	ProposalStatusCompleted ProposalStatus = 0x25

	//Proposal Outcome
	ProposalOutcomeInProgress        ProposalOutcome = 0x26
	ProposalOutcomeInsufficientFunds ProposalOutcome = 0x27
	ProposalOutcomeInsufficientVotes ProposalOutcome = 0x28
	ProposalOutcomeCancelled         ProposalOutcome = 0x29
	ProposalOutcomeCompleted         ProposalOutcome = 0x30

	//Proposal States
	ProposalStateError  ProposalState = 0xEE
	ProposalStateActive ProposalState = 0x31
	ProposalStatePassed ProposalState = 0x32
	ProposalStateFailed ProposalState = 0x33

	//Vote Opinions
	OPIN_UNKNOWN  VoteOpinion = 0
	OPIN_POSITIVE VoteOpinion = 1
	OPIN_NEGATIVE VoteOpinion = 2
	OPIN_GIVEUP   VoteOpinion = 3
)
View Source
const (
	ADMIN_INITIAL_KEY    string = "initial"
	ADMIN_CURRENCY_KEY   string = "currency"
	ADMIN_FEE_OPTION_KEY string = "feeopt"

	ADMIN_EPOCH_BLOCK_INTERVAL string = "epoch"

	ADMIN_ETH_CHAINDRIVER_OPTION string = "ethcdopt"

	ADMIN_BTC_CHAINDRIVER_OPTION string = "btccdopt"
	ADMIN_ONS_OPTION             string = "onsopt"

	ADMIN_PROPOSAL_OPTION string = "proposal"
)
View Source
const EmptyStr = ""

Variables

View Source
var (
	//Vote Error
	ErrVoteSetupValidatorFailed    = codes.ProtocolError{Code: codes.GovErrVoteSetupValidator, Msg: "ErrVote, failed to setup voting validator"}
	ErrVoteUpdateVoteFailed        = codes.ProtocolError{Code: codes.GovErrVoteUpdateVote, Msg: "ErrVote, failed to vote proposal"}
	ErrVoteDeleteVoteRecordsFailed = codes.ProtocolError{Code: codes.GovErrVoteDeleteVoteRecords, Msg: "ErrVote, failed to delete voting records"}
	ErrVoteCheckVoteResultFailed   = codes.ProtocolError{Code: codes.GovErrVoteCheckVoteResult, Msg: "ErrVote, failed to check voting result"}
)

Functions

func GetKey added in v0.14.2

func GetKey(prefix []byte, proposalID ProposalID, vote *ProposalVote) []byte

Types

type Proposal added in v0.14.2

type Proposal struct {
	ProposalID      ProposalID
	Type            ProposalType
	Status          ProposalStatus
	Outcome         ProposalOutcome
	Description     string
	Proposer        keys.Address
	FundingDeadline int64
	FundingGoal     int64
	VotingDeadline  int64
}

func NewProposal added in v0.14.2

func NewProposal(propType ProposalType, desc string, proposer keys.Address, fundingDeadline int64, fundingGoal int64,
	votingDeadline int64) *Proposal

type ProposalAmount added in v0.14.2

type ProposalAmount big.Int

func NewAmount added in v0.14.2

func NewAmount(x int64) *ProposalAmount

func NewAmountFromInt added in v0.14.2

func NewAmountFromInt(x int64) *ProposalAmount

func (*ProposalAmount) BigInt added in v0.14.2

func (p *ProposalAmount) BigInt() *big.Int

func (ProposalAmount) MarshalJSON added in v0.14.2

func (p ProposalAmount) MarshalJSON() ([]byte, error)

func (ProposalAmount) Plus added in v0.14.2

func (ProposalAmount) String added in v0.14.2

func (p ProposalAmount) String() string

func (*ProposalAmount) UnmarshalJSON added in v0.14.2

func (p *ProposalAmount) UnmarshalJSON(b []byte) error

type ProposalFund added in v0.14.2

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

func (*ProposalFund) Print added in v0.14.2

func (fund *ProposalFund) Print()

type ProposalFundStore added in v0.14.2

type ProposalFundStore struct {
	State *storage.State
	// contains filtered or unexported fields
}

func NewProposalFundStore added in v0.14.2

func NewProposalFundStore(prefix string, state *storage.State) *ProposalFundStore

Store Function Called my external Layers

func (*ProposalFundStore) AddFunds added in v0.14.2

func (pf *ProposalFundStore) AddFunds(proposalId ProposalID, fundingAddress keys.Address, amount *ProposalAmount) error

func (*ProposalFundStore) DeleteFunds added in v0.14.2

func (pf *ProposalFundStore) DeleteFunds(proposalId ProposalID, fundingAddress keys.Address) (bool, error)

func (*ProposalFundStore) GetFundersForProposalID added in v0.14.2

func (pf *ProposalFundStore) GetFundersForProposalID(id ProposalID, fn func(proposalID ProposalID, fundingAddr keys.Address, amt *ProposalAmount) ProposalFund) []ProposalFund

func (*ProposalFundStore) GetProposalsForFunder added in v0.14.2

func (pf *ProposalFundStore) GetProposalsForFunder(funderAddress keys.Address, fn func(proposalID ProposalID, fundingAddr keys.Address, amt *ProposalAmount) ProposalFund) []ProposalFund

type ProposalID added in v0.14.2

type ProposalID string

type ProposalOptions added in v0.14.2

type ProposalOptions struct {
	ConfigUpdate options
	CodeChange   options
	General      options
}

type ProposalOutcome added in v0.14.2

type ProposalOutcome int

type ProposalState added in v0.14.2

type ProposalState int

type ProposalStatus added in v0.14.2

type ProposalStatus int

type ProposalStore added in v0.14.2

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

func NewProposalStore added in v0.14.2

func NewProposalStore(prefixActive string, prefixPassed string, prefixFailed string, state *storage.State) *ProposalStore

func (*ProposalStore) Delete added in v0.14.2

func (ps *ProposalStore) Delete(key ProposalID) (bool, error)

func (*ProposalStore) Exists added in v0.14.2

func (ps *ProposalStore) Exists(key ProposalID) bool

func (*ProposalStore) Get added in v0.14.2

func (ps *ProposalStore) Get(proposalID ProposalID) (*Proposal, error)

func (*ProposalStore) GetIterable added in v0.14.2

func (ps *ProposalStore) GetIterable() storage.Iterable

func (*ProposalStore) GetOptions added in v0.14.2

func (ps *ProposalStore) GetOptions() *ProposalOptions

func (*ProposalStore) Iterate added in v0.14.2

func (ps *ProposalStore) Iterate(fn func(id ProposalID, proposal *Proposal) bool) (stopped bool)

func (*ProposalStore) IterateProposalType added in v0.14.2

func (ps *ProposalStore) IterateProposalType(fn func(id ProposalID, proposal *Proposal) bool, proposalType ProposalType) (stopped bool)

func (*ProposalStore) IterateProposer added in v0.14.2

func (ps *ProposalStore) IterateProposer(fn func(id ProposalID, proposal *Proposal) bool, proposer keys.Address) (stopped bool)

func (*ProposalStore) QueryAllStores added in v0.14.2

func (ps *ProposalStore) QueryAllStores(key ProposalID) (*Proposal, ProposalState, error)

func (*ProposalStore) Set added in v0.14.2

func (ps *ProposalStore) Set(proposal *Proposal) error

func (*ProposalStore) SetOptions added in v0.14.2

func (ps *ProposalStore) SetOptions(pOpt *ProposalOptions)

func (*ProposalStore) WithPrefix added in v0.14.2

func (ps *ProposalStore) WithPrefix(prefix []byte) *ProposalStore

func (*ProposalStore) WithPrefixType added in v0.14.2

func (ps *ProposalStore) WithPrefixType(prefixType ProposalState) *ProposalStore

func (*ProposalStore) WithState added in v0.14.2

func (ps *ProposalStore) WithState(state *storage.State) *ProposalStore

type ProposalType added in v0.14.2

type ProposalType int

type ProposalVote added in v0.14.2

type ProposalVote struct {
	Validator keys.Address
	Opinion   VoteOpinion
	Power     int64
}

func NewProposalVote added in v0.14.2

func NewProposalVote(validator keys.Address, opinion VoteOpinion, power int64) *ProposalVote

func (*ProposalVote) Bytes added in v0.14.2

func (vote *ProposalVote) Bytes() []byte

func (*ProposalVote) FromBytes added in v0.14.2

func (vote *ProposalVote) FromBytes(msg []byte) (*ProposalVote, error)

func (*ProposalVote) String added in v0.14.2

func (vote *ProposalVote) String() string

type ProposalVoteStore added in v0.14.2

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

func NewProposalVoteStore added in v0.14.2

func NewProposalVoteStore(prefix string, state *storage.State) *ProposalVoteStore

func (*ProposalVoteStore) Delete added in v0.14.2

func (pvs *ProposalVoteStore) Delete(proposalID ProposalID) error

Delete all voting records under a proposalID

func (*ProposalVoteStore) GetVotesByID added in v0.14.2

func (pvs *ProposalVoteStore) GetVotesByID(proposalID ProposalID) ([]keys.Address, []*ProposalVote, error)

get voting votes by proposalID

func (*ProposalVoteStore) IsPassed added in v0.14.2

func (pvs *ProposalVoteStore) IsPassed(proposalID ProposalID, passPercent int64) (bool, error)

Check and see if a proposal has passed

func (*ProposalVoteStore) IterateByID added in v0.14.2

func (pvs *ProposalVoteStore) IterateByID(proposalID ProposalID, fn func(key []byte, value []byte) bool) (stopped bool)

Iterate voting records by proposalID

func (*ProposalVoteStore) Setup added in v0.14.2

func (pvs *ProposalVoteStore) Setup(proposalID ProposalID, vote *ProposalVote) error

Setup an initial voting validator to proposalID

func (*ProposalVoteStore) Update added in v0.14.2

func (pvs *ProposalVoteStore) Update(proposalID ProposalID, vote *ProposalVote) error

Update a validator's voting opinion to proposalID

func (*ProposalVoteStore) WithState added in v0.14.2

func (pvs *ProposalVoteStore) WithState(state *storage.State) *ProposalVoteStore

type Store

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

func NewStore

func NewStore(prefix string, state *storage.State) *Store

func (*Store) Exists

func (st *Store) Exists(key []byte) bool

func (*Store) Get

func (st *Store) Get(key []byte) ([]byte, error)

func (*Store) GetBTCChainDriverOption added in v0.14.0

func (st *Store) GetBTCChainDriverOption() (*bitcoin.ChainDriverOption, error)

func (*Store) GetCurrencies

func (st *Store) GetCurrencies() (balance.Currencies, error)

func (*Store) GetETHChainDriverOption added in v0.13.0

func (st *Store) GetETHChainDriverOption() (*ethchain.ChainDriverOption, error)

func (*Store) GetEpoch added in v0.13.0

func (st *Store) GetEpoch() (int64, error)

func (*Store) GetFeeOption

func (st *Store) GetFeeOption() (*fees.FeeOption, error)

func (*Store) GetONSOptions added in v0.14.0

func (st *Store) GetONSOptions() (*ons.Options, error)

func (*Store) GetProposalOptions added in v0.14.2

func (st *Store) GetProposalOptions() (*ProposalOptions, error)

func (*Store) InitialChain

func (st *Store) InitialChain() bool

func (*Store) Initiated

func (st *Store) Initiated() bool

func (*Store) Set

func (st *Store) Set(key []byte, value []byte) error

func (*Store) SetBTCChainDriverOption added in v0.14.0

func (st *Store) SetBTCChainDriverOption(opt bitcoin.ChainDriverOption) error

func (*Store) SetCurrencies

func (st *Store) SetCurrencies(currencies balance.Currencies) error

func (*Store) SetETHChainDriverOption added in v0.13.0

func (st *Store) SetETHChainDriverOption(opt ethchain.ChainDriverOption) error

func (*Store) SetEpoch added in v0.13.0

func (st *Store) SetEpoch(epoch int64) error

func (*Store) SetFeeOption

func (st *Store) SetFeeOption(feeOpt fees.FeeOption) error

func (*Store) SetONSOptions added in v0.14.0

func (st *Store) SetONSOptions(onsOpt ons.Options) error

func (*Store) SetProposalOptions added in v0.14.2

func (st *Store) SetProposalOptions(propOpt ProposalOptions) error

func (*Store) WithState

func (st *Store) WithState(state *storage.State) *Store

type VoteOpinion added in v0.14.2

type VoteOpinion int

func (VoteOpinion) String added in v0.14.2

func (opinion VoteOpinion) String() string

Jump to

Keyboard shortcuts

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