governance

package
v0.18.15 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Proposal Types
	ProposalTypeInvalid      ProposalType = 0xEE
	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
	ProposalOutcomeCompletedNo       ProposalOutcome = 0x29
	ProposalOutcomeCancelled         ProposalOutcome = 0x30
	ProposalOutcomeCompletedYes      ProposalOutcome = 0x31

	//Proposal States
	ProposalStateInvalid        ProposalState = 0xEE
	ProposalStateActive         ProposalState = 0x32
	ProposalStatePassed         ProposalState = 0x33
	ProposalStateFailed         ProposalState = 0x34
	ProposalStateFinalized      ProposalState = 0x35
	ProposalStateFinalizeFailed ProposalState = 0x36

	//Vote Opinions
	OPIN_UNKNOWN  VoteOpinion = 0x0
	OPIN_POSITIVE VoteOpinion = 0x1
	OPIN_NEGATIVE VoteOpinion = 0x2
	OPIN_GIVEUP   VoteOpinion = 0x3

	//Vote Result
	VOTE_RESULT_PASSED VoteResult = 0x10
	VOTE_RESULT_FAILED VoteResult = 0x11
	VOTE_RESULT_TBD    VoteResult = 0x12

	//Proposal ID length based on hash algorithm
	SHA256LENGTH int = 0x40
)
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"

	ADMIN_STAKING_OPTION string = "stakingopt"

	ADMIN_REWARD_OPTION string = "reward"

	ADMIN_EVIDENCE_OPTION string = "evidenceopt"

	ADMIN_NETWK_DELEG_OPTION string = "networkdelegopt"

	TOTAL_FUNDS_PREFIX string = "t"

	INDIVIDUAL_FUNDS_PREFIX string = "i"

	LAST_UPDATE_HEIGHT             string = "defaultOptions"
	LAST_UPDATE_HEIGHT_CURRENCY    string = "currencyOptions"
	LAST_UPDATE_HEIGHT_FEE         string = "feeOptions"
	LAST_UPDATE_HEIGHT_ETH         string = "ethOptions"
	LAST_UPDATE_HEIGHT_BTC         string = "btcOptions"
	LAST_UPDATE_HEIGHT_REWARDS     string = "rewardsOptions"
	LAST_UPDATE_HEIGHT_STAKING     string = "stakingOptions"
	LAST_UPDATE_HEIGHT_NETWK_DELEG string = "delegOptions"
	LAST_UPDATE_HEIGHT_ONS         string = "onsOptions"
	LAST_UPDATE_HEIGHT_PROPOSAL    string = "proposalOptions"
	LAST_UPDATE_HEIGHT_EVIDENCE    string = "evidenceOptions"
	HEIGHT_INDEPENDENT_VALUE       string = "heightindependent"

	// Pool names
	POOL_BOUNTY     = "BountyPool"
	POOL_FEE        = "FeePool"
	POOL_REWARDS    = "RewardsPool"
	POOL_DELEGATION = "DelegationPool"
)
View Source
const EmptyStr = ""

Variables

View Source
var (
	// Options Objects from store
	ErrGetProposalOptions = codes.ProtocolError{codes.GovErrGetProposalOptions, "failed to get proposal options"}
	ErrGetFeeOptions      = codes.ProtocolError{codes.TxErrGettingFeeOptions, "failed to get fee options"}
	ErrGetRewardOptions   = codes.ProtocolError{codes.TxErrGettingRewardsOptions, "failed to get Reward options"}
	ErrGetONSOptions      = codes.ProtocolError{codes.TxErrGettingONSOptions, "failed to get ONS options"}
	ErrGetEthOptions      = codes.ProtocolError{codes.TxErrGettingETHOptions, "failed to get ETH options"}
	ErrGetStakingOptions  = codes.ProtocolError{codes.TxErrGetStakingOptions, "failed to get Staking options"}
	ErrGetBtcOptions      = codes.ProtocolError{codes.TxErrGettingBTCOptions, "failed to get BTC options"}
	ErrValidateGovState   = codes.ProtocolError{codes.TxErrValidateGovState, "failed to validate gov state"}
	ErrInvalidOptions     = codes.ProtocolError{codes.TxErrInvalidOptions, "Set Options string is invalid"}

	//Proposal
	ErrInvalidProposalId      = codes.ProtocolError{codes.GovErrInvalidProposalId, "invalid proposal id"}
	ErrInvalidProposalType    = codes.ProtocolError{codes.GovErrInvalidProposalType, "invalid proposal type"}
	ErrInvalidProposalDesc    = codes.ProtocolError{codes.GovErrInvalidProposalDesc, "invalid description of proposal"}
	ErrProposalExists         = codes.ProtocolError{codes.GovErrProposalExists, "proposal already exists"}
	ErrProposalNotExists      = codes.ProtocolError{codes.GovErrProposalNotExists, "proposal not exists"}
	ErrInvalidBeneficiaryAddr = codes.ProtocolError{codes.GovErrInvalidBeneficiaryAddr, "invalid withdraw beneficiary address"}
	ErrInvalidFundingGoal     = codes.ProtocolError{codes.GovErrInvalidFundingGoal, "invalid funding goal"}
	ErrInvalidPassPercentage  = codes.ProtocolError{codes.GovErrInvalidPassPercentage, "invalid pass percentage"}
	ErrInvalidFundingDeadline = codes.ProtocolError{codes.GovErrInvalidFundingDeadline, "invalid funding deadline"}
	ErrInvalidVotingDeadline  = codes.ProtocolError{codes.GovErrInvalidVotingDeadline, "invalid voting deadline"}

	//Funding
	ErrDeductFunding          = codes.ProtocolError{codes.GovErrDeductFunding, "failed to deduct funds from address"}
	ErrAddFunding             = codes.ProtocolError{codes.GovErrAddFunding, "failed to add funds to address"}
	ErrInvalidFunderAddr      = codes.ProtocolError{codes.GovErrInvalidFunderAddr, "invalid funder address"}
	ErrStatusNotFunding       = codes.ProtocolError{Code: codes.GovErrStatusNotFunding, Msg: "TX not in Funding status"}
	ErrGovFundUnableToAdd     = codes.ProtocolError{Code: codes.GovFundUnableToAdd, Msg: "Funding unable to add funds"}
	ErrGovFundUnableToDelete  = codes.ProtocolError{Code: codes.GovFundUnableToDelete, Msg: "Funding unable to delete Funds"}
	ErrFundingDeadlineCrossed = codes.ProtocolError{Code: codes.GovErrFundingDeadlineCrossed, Msg: "Funding deadline has been crossed"}

	//Voting
	ErrSetupVotingValidator        = codes.ProtocolError{codes.GovErrSetupVotingValidator, "failed to setup voting validator"}
	ErrStatusNotVoting             = codes.ProtocolError{Code: codes.GovErrStatusNotVoting, Msg: "TX not in Voting status"}
	ErrVotingHeightReached         = codes.ProtocolError{codes.GovErrVotingHeightReached, "voting height has already been reached"}
	ErrAddingVoteToVoteStore       = codes.ProtocolError{codes.GovErrAddingVoteToVoteStore, "failed to add vote to vote store"}
	ErrPeekingVoteResult           = codes.ProtocolError{codes.GovErrPeekingVoteResult, "failed to peek vote result"}
	ErrInvalidVoteOpinion          = codes.ProtocolError{codes.GovErrInvalidVoteOpinion, "invalid vote opinion"}
	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"}
	ErrStatusUnableToSetVoting     = codes.ProtocolError{Code: codes.StatusUnableToSetVoting, Msg: "Failed to set status to voting"}
	ErrUnabletoQueryVoteResult     = codes.ProtocolError{Code: codes.GovErrUnabletoQueryVoteResult, Msg: "Unable to query Votestore to get Vote result"}
	ErrVotingTBD                   = codes.ProtocolError{Code: codes.GovErrVotingTBD, Msg: "Voting Decision not achieved"}

	//Finalizing
	ErrStatusNotCompleted              = codes.ProtocolError{Code: codes.GovErrStatusNotCompleted, Msg: "TX not in completed status"}
	ErrFinalizeDistributtionFailed     = codes.ProtocolError{Code: codes.GovErrFinalizeDistributtionFailed, Msg: "Failed in distributing Funds"}
	ErrFinalizeConfigUpdateFailed      = codes.ProtocolError{Code: codes.GovErrFinalizeConfigUpdateFailed, Msg: "Failed to execute Config Update"}
	ErrStatusUnableToSetFinalized      = codes.ProtocolError{Code: codes.GovErrStatusUnableToSetFinalized, Msg: "Failed to set status to finalized"}
	ErrStatusUnableToSetFinalizeFailed = codes.ProtocolError{Code: codes.GovErrUnableToSetFinalizeFailed, Msg: "Failed to set status to finalized Failed"}
	ErrGovFundBalanceMismatch          = codes.ProtocolError{Code: codes.GovFundBalanceMismatch, Msg: "Balance Mismatch While Burning Funds"}

	//Withdraw
	ErrProposalWithdrawNotEligible = codes.ProtocolError{codes.GovErrProposalWithdrawNotEligible, "proposal does not meet withdraw requirement"}
	ErrNoSuchFunder                = codes.ProtocolError{codes.GovErrNoSuchFunder, "no such funder funded this proposal"}
	ErrUnmatchedProposer           = codes.ProtocolError{codes.GovErrUnmatchedProposer, "proposer does not match"}
	ErrInvalidVoterId              = codes.ProtocolError{codes.GovErrInvalidVoterId, "invalid voter id"}
	ErrWithdrawCheckFundsFailed    = codes.ProtocolError{Code: codes.GovErrWithdrawCheckFundsFailed, Msg: "ErrWithdraw, failed to check available funds to withdraw for this contributor"}

	//Proposal Prefix
	ErrAddingProposalToActiveStore     = codes.ProtocolError{codes.GovErrAddingProposalToActiveStore, "failed to add proposal to ACTIVE store"}
	ErrDeletingProposalFromActiveStore = codes.ProtocolError{codes.GovErrDeletingProposalFromActiveStore, "failed to delet proposal from ACTIVE store"}
	ErrAddingProposalToPassedStore     = codes.ProtocolError{codes.GovErrAddingProposalToPassedStore, "failed to add proposal to PASSED store"}
	ErrAddingProposalToFailedStore     = codes.ProtocolError{codes.GovErrAddingProposalToFailedStore, "failed to add proposal to FAILED store"}
	ErrDeletingProposalFromFailedStore = codes.ProtocolError{codes.GovErrDeletingProposalFromFailedStore, "failed to delet proposal from FAILED store"}
)
View Source
var (

	//Evidence
	MinVotesRequiredPercentage = int64(70)
)

Functions

func GetKey added in v0.14.2

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

Types

type GovProposal added in v0.14.4

type GovProposal struct {
	Prop          Proposal        `json:"proposal"`
	ProposalVotes []*ProposalVote `json:"proposalVotes"`
	ProposalFunds []ProposalFund  `json:"proposalFunds"`
	State         ProposalState
}

type GovernanceState added in v0.14.3

type GovernanceState struct {
	FeeOption       fees.FeeOption             `json:"feeOption"`
	ETHCDOption     ethchain.ChainDriverOption `json:"ethchaindriverOption"`
	BTCCDOption     bitcoin.ChainDriverOption  `json:"bitcoinChainDriverOption"`
	ONSOptions      ons.Options                `json:"onsOptions"`
	PropOptions     ProposalOptionSet          `json:"propOptions"`
	StakingOptions  delegation.Options         `json:"stakingOptions"`
	DelegOptions    network_delegation.Options `json:"delegOptions"`
	EvidenceOptions evidence.Options           `json:"evidenceOptions"`
	RewardOptions   rewards.Options            `json:"rewardOptions"`
}

type Proposal added in v0.14.2

type Proposal struct {
	ProposalID            ProposalID      `json:"proposalId"`
	Type                  ProposalType    `json:"proposalType"`
	Status                ProposalStatus  `json:"status"`
	Outcome               ProposalOutcome `json:"outcome"`
	Headline              string          `json:"headline"`
	Description           string          `json:"descr"`
	Proposer              keys.Address    `json:"proposer"`
	FundingDeadline       int64           `json:"fundingDeadline"`
	FundingGoal           *balance.Amount `json:"fundingGoal"`
	VotingDeadline        int64           `json:"votingDeadline"`
	PassPercentage        int             `json:"passPercent"`
	GovernanceStateUpdate string          `json:"updateGovernanace"`
}

func NewProposal added in v0.14.2

func NewProposal(proposalID ProposalID, propType ProposalType, desc string, headline string, proposer keys.Address, fundingDeadline int64, fundingGoal *balance.Amount,
	votingDeadline int64, passPercentage int, upd string) *Proposal

type ProposalFund added in v0.14.2

type ProposalFund struct {
	Id            ProposalID      `json:"id"`
	Address       keys.Address    `json:"address"`
	FundingAmount *balance.Amount `json:"fundingAmount"`
}

func (*ProposalFund) Print added in v0.14.2

func (fund *ProposalFund) Print()

type ProposalFundDistribution added in v0.14.3

type ProposalFundDistribution struct {
	Validators     float64 `json:"validators"`
	FeePool        float64 `json:"feePool"`
	Burn           float64 `json:"burn"`
	ExecutionCost  float64 `json:"executionCost"`
	BountyPool     float64 `json:"bountyPool"`
	ProposerReward float64 `json:"proposerReward"`
}

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 *balance.Amount) error

func (*ProposalFundStore) DeductFunds added in v0.14.3

func (pf *ProposalFundStore) DeductFunds(proposalId ProposalID, fundingAddress keys.Address, amount *balance.Amount) error

func (*ProposalFundStore) DeleteAllFunds added in v0.14.3

func (pf *ProposalFundStore) DeleteAllFunds(id ProposalID) error

func (*ProposalFundStore) DeleteFunds added in v0.14.2

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

func (*ProposalFundStore) GetCurrentFundsForProposal added in v0.14.3

func (pf *ProposalFundStore) GetCurrentFundsForProposal(proposalID ProposalID) *balance.Amount

func (*ProposalFundStore) GetFundsForProposalByFunder added in v0.14.3

func (pf *ProposalFundStore) GetFundsForProposalByFunder(proposalID ProposalID, funder keys.Address) *balance.Amount

func (*ProposalFundStore) GetFundsForProposalID added in v0.14.3

func (pf *ProposalFundStore) GetFundsForProposalID(id ProposalID, fn func(proposalID ProposalID, fundingAddr keys.Address, amt *balance.Amount) 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 *balance.Amount) ProposalFund) []ProposalFund

func (*ProposalFundStore) IsFundedByFunder added in v0.14.3

func (pf *ProposalFundStore) IsFundedByFunder(id ProposalID, funder keys.Address) bool

func (*ProposalFundStore) WithState added in v0.14.3

func (pf *ProposalFundStore) WithState(state *storage.State) *ProposalFundStore

type ProposalID added in v0.14.2

type ProposalID string

func (ProposalID) Err added in v0.14.3

func (id ProposalID) Err() error

func (ProposalID) String added in v0.14.3

func (id ProposalID) String() string

type ProposalMasterStore added in v0.14.3

type ProposalMasterStore struct {
	Proposal     *ProposalStore
	ProposalFund *ProposalFundStore
	ProposalVote *ProposalVoteStore
}

func NewProposalMasterStore added in v0.14.3

func NewProposalMasterStore(p *ProposalStore, pf *ProposalFundStore, pv *ProposalVoteStore) *ProposalMasterStore

func (*ProposalMasterStore) GetProposalFunds added in v0.14.4

func (p *ProposalMasterStore) GetProposalFunds(id ProposalID) []ProposalFund

func (*ProposalMasterStore) GetProposalVotes added in v0.14.4

func (p *ProposalMasterStore) GetProposalVotes(id ProposalID) []*ProposalVote

func (*ProposalMasterStore) LoadProposals added in v0.14.4

func (p *ProposalMasterStore) LoadProposals(proposals []GovProposal) error

func (*ProposalMasterStore) WithState added in v0.14.3

func (p *ProposalMasterStore) WithState(state *storage.State) *ProposalMasterStore

type ProposalOption added in v0.14.3

type ProposalOption struct {
	InitialFunding         *balance.Amount          `json:"initialFunding"`
	FundingGoal            *balance.Amount          `json:"fundingGoal"`
	FundingDeadline        int64                    `json:"fundingDeadline"`
	VotingDeadline         int64                    `json:"votingDeadline"`
	PassPercentage         int                      `json:"passPercentage"`
	PassedFundDistribution ProposalFundDistribution `json:"passedFundDistribution"`
	FailedFundDistribution ProposalFundDistribution `json:"failedFundDistribution"`
	ProposalExecutionCost  string                   `json:"proposalExecutionCost"`
}

type ProposalOptionSet added in v0.14.3

type ProposalOptionSet struct {
	ConfigUpdate      ProposalOption `json:"configUpdate"`
	CodeChange        ProposalOption `json:"codeChange"`
	General           ProposalOption `json:"general"`
	BountyProgramAddr string         `json:"bountyProgramAddr"`
}

type ProposalOutcome added in v0.14.2

type ProposalOutcome int

func (ProposalOutcome) String added in v0.14.3

func (outCome ProposalOutcome) String() string

type ProposalState added in v0.14.2

type ProposalState int

func NewProposalState added in v0.14.3

func NewProposalState(prefix string) ProposalState

func (ProposalState) String added in v0.14.3

func (state ProposalState) String() string

type ProposalStatus added in v0.14.2

type ProposalStatus int

func (ProposalStatus) String added in v0.14.3

func (status ProposalStatus) String() string

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, prefixFinalized string, prefixFinalizeFailed 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) FilterProposals added in v0.14.3

func (ps *ProposalStore) FilterProposals(state ProposalState, proposer keys.Address, pType ProposalType) []Proposal

Filter proposals by Proposer and Type in a specified store

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() *ProposalOptionSet

func (*ProposalStore) GetOptionsByType added in v0.14.3

func (ps *ProposalStore) GetOptionsByType(typ ProposalType) *ProposalOption

func (*ProposalStore) GetState added in v0.14.3

func (ps *ProposalStore) GetState() *storage.State

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 *ProposalOptionSet)

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

func NewProposalType added in v0.14.3

func NewProposalType(propType string) ProposalType

func (ProposalType) String added in v0.14.3

func (propType ProposalType) String() string

type ProposalVote added in v0.14.2

type ProposalVote struct {
	Validator keys.Address `json:"validator"`
	Opinion   VoteOpinion  `json:"opinion"`
	Power     int64        `json:"power"`
}

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) 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) ResultSoFar added in v0.14.3

func (pvs *ProposalVoteStore) ResultSoFar(proposalID ProposalID, passPercent int) (*VoteStatus, error)

ResultSoFar check and see if a proposal has already passed or failed Proposal passed if passPercent already achieved Proposal never pass if received enough NEGATIVE votes

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 string, optKey string) ([]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) GetEvidenceOptions added in v0.15.1

func (st *Store) GetEvidenceOptions() (*evidence.Options, error)

func (*Store) GetFeeOption

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

func (*Store) GetLUH added in v0.14.3

func (st *Store) GetLUH(optKey string) (int64, error)

LUH -> LAST_UPDATE_HEIGHT_LAST_UPDATE_HEIGHT_FEE FEEOPTION ->(CurrentHeight) + storage.DB_PREFIX + optionKey + storage.DB_PREFIX + FeeOption)

func (*Store) GetNetworkDelegOptions added in v0.16.1

func (st *Store) GetNetworkDelegOptions() (*network_delegation.Options, error)

func (*Store) GetONSOptions added in v0.14.0

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

func (*Store) GetPoolByName added in v0.16.1

func (st *Store) GetPoolByName(poolName string) (address keys.Address, err error)

func (*Store) GetPoolList added in v0.14.4

func (st *Store) GetPoolList() (map[string]keys.Address, error)

func (*Store) GetProposalOptions added in v0.14.2

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

func (*Store) GetProposalOptionsByType added in v0.14.3

func (st *Store) GetProposalOptionsByType(ptype ProposalType) (*ProposalOption, error)

func (*Store) GetRewardOptions added in v0.14.3

func (st *Store) GetRewardOptions() (*rewards.Options, error)

func (*Store) GetStakingOptions added in v0.14.3

func (st *Store) GetStakingOptions() (*delegation.Options, error)

func (*Store) GetUnversioned added in v0.14.3

func (st *Store) GetUnversioned(key string, optKey string) ([]byte, 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 string, value []byte) error

func (*Store) SetAllLUH added in v0.15.1

func (st *Store) SetAllLUH() 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) SetEvidenceOptions added in v0.15.1

func (st *Store) SetEvidenceOptions(opt evidence.Options) error

func (*Store) SetFeeOption

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

func (*Store) SetLUH added in v0.14.3

func (st *Store) SetLUH(optKey string) error

func (*Store) SetNetworkDelegOptions added in v0.16.1

func (st *Store) SetNetworkDelegOptions(delegOptions network_delegation.Options) 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 ProposalOptionSet) error

func (*Store) SetRewardOptions added in v0.14.3

func (st *Store) SetRewardOptions(rewardOptions rewards.Options) error

func (*Store) SetStakingOptions added in v0.14.3

func (st *Store) SetStakingOptions(opt delegation.Options) error

func (*Store) SetUnversioned added in v0.14.3

func (st *Store) SetUnversioned(key string, optKey string, value []byte) error

LUH FORMAT KEY :LAST_UPDATE_HEIGHT_LAST_UPDATE_HEIGHT_FEE (Key for each option) VALUE : 0 (Height)

func (*Store) ValidateBTC added in v0.14.4

func (st *Store) ValidateBTC(opt *bitcoin.ChainDriverOption) (bool, error)

func (*Store) ValidateETH added in v0.14.4

func (st *Store) ValidateETH(opt *ethchain.ChainDriverOption) (bool, error)

func (*Store) ValidateEvidence added in v0.15.1

func (st *Store) ValidateEvidence(opt *evidence.Options) (bool, error)

func (*Store) ValidateFee added in v0.14.4

func (st *Store) ValidateFee(opt *fees.FeeOption) (bool, error)

func (*Store) ValidateGov added in v0.14.4

func (st *Store) ValidateGov(govstate GovernanceState) (bool, error)

func (*Store) ValidateNetwkDeleg added in v0.16.1

func (st *Store) ValidateNetwkDeleg(opt *network_delegation.Options) (bool, error)

func (*Store) ValidateONS added in v0.14.4

func (st *Store) ValidateONS(opt *ons.Options) (bool, error)

func (*Store) ValidateProposal added in v0.14.4

func (st *Store) ValidateProposal(opt *ProposalOptionSet) (bool, error)

func (*Store) ValidateRewards added in v0.14.4

func (st *Store) ValidateRewards(opt *rewards.Options) (bool, error)

func (*Store) ValidateStaking added in v0.14.4

func (st *Store) ValidateStaking(opt *delegation.Options) (bool, error)

func (*Store) WithHeight added in v0.14.3

func (st *Store) WithHeight(height int64) *Store

func (*Store) WithState

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

type VoteOpinion added in v0.14.2

type VoteOpinion int

func NewVoteOpinion added in v0.14.3

func NewVoteOpinion(opin string) VoteOpinion

func (VoteOpinion) Err added in v0.14.3

func (opinion VoteOpinion) Err() error

func (VoteOpinion) String added in v0.14.2

func (opinion VoteOpinion) String() string

type VoteResult added in v0.14.3

type VoteResult int

func (VoteResult) String added in v0.14.3

func (opinion VoteResult) String() string

type VoteStatus added in v0.14.3

type VoteStatus struct {
	Result   VoteResult `json:"result"`
	PowerYes int64      `json:"powerYes"`
	PowerNo  int64      `json:"powerNo"`
	PowerAll int64      `json:"powerAll"`
}

func NewVoteStatus added in v0.14.3

func NewVoteStatus(result VoteResult, yesPower, noPower, allPower int64) *VoteStatus

Jump to

Keyboard shortcuts

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