Documentation ¶
Index ¶
- Constants
- func BuildQueryDepositPath(pid int64, depositAddr string) string
- func BuildQueryDepositsPath(pid int64) string
- func BuildQueryModuleParamsPath(module string) string
- func BuildQueryParamPath(module string, key string) string
- func BuildQueryParamsPath() string
- func BuildQueryProposalPath(pid int64) string
- func BuildQueryProposalsPath() string
- func BuildQueryTallyPath(pid int64) string
- func BuildQueryVotePath(pid int64, voterAddr string) string
- func BuildQueryVotesPath(pid int64) string
- func DepositInvariant(module string) qtypes.Invariant
- func Query(ctx context.Context, route []string, req abci.RequestQuery) (res []byte, err btypes.Error)
- func Tally(ctx context.Context, mapper *Mapper, proposal gtypes.Proposal) (passes gtypes.ProposalResult, tallyResults gtypes.TallyResult, ...)
- type Mapper
- func (mapper Mapper) ActiveProposalQueueIterator(endTime time.Time) store.Iterator
- func (mapper Mapper) AddDeposit(ctx context.Context, proposalID int64, depositorAddr btypes.AccAddress, ...) (btypes.Error, bool)
- func (mapper Mapper) AddVote(proposalID int64, voterAddr btypes.AccAddress, option types.VoteOption) btypes.Error
- func (mapper *Mapper) Copy() mapper.IMapper
- func (mapper Mapper) DeleteDeposits(ctx context.Context, proposalID int64)
- func (mapper Mapper) DeleteProposal(proposalID int64)
- func (mapper Mapper) DeleteValidatorSet(proposalID int64)
- func (mapper Mapper) DeleteVotes(proposalID int64)
- func (mapper Mapper) ExistsUnfinishedProposals(ctx context.Context, proposalType types.ProposalType) bool
- func (mapper Mapper) GetDeposit(proposalID int64, depositorAddr btypes.AccAddress) (deposit types.Deposit, exists bool)
- func (mapper Mapper) GetDeposits(proposalID int64) store.Iterator
- func (mapper Mapper) GetLastProposalID() (proposalID int64)
- func (mapper Mapper) GetLevelParams(ctx context.Context, level types.ProposalLevel) types.LevelParams
- func (mapper Mapper) GetParams(ctx context.Context) types.Params
- func (mapper Mapper) GetProposal(proposalID int64) (proposal types.Proposal, ok bool)
- func (mapper Mapper) GetProposals() []types.Proposal
- func (mapper Mapper) GetProposalsFiltered(ctx context.Context, voterAddr, depositorAddr btypes.AccAddress, ...) []types.Proposal
- func (mapper Mapper) GetValidatorSet(proposalID int64) (validators []btypes.ValAddress, exists bool)
- func (mapper Mapper) GetVote(proposalID int64, voterAddr btypes.AccAddress) (vote types.Vote, exists bool)
- func (mapper Mapper) GetVotes(proposalID int64) store.Iterator
- func (mapper Mapper) InactiveProposalQueueIterator(endTime time.Time) store.Iterator
- func (mapper Mapper) InsertActiveProposalQueue(endTime time.Time, proposalID int64)
- func (mapper Mapper) InsertInactiveProposalQueue(endTime time.Time, proposalID int64)
- func (mapper Mapper) PeekCurrentProposalID() (proposalID int64, err btypes.Error)
- func (mapper Mapper) RefundDeposits(ctx context.Context, proposalID int64, level types.ProposalLevel, ...)
- func (mapper Mapper) RemoveFromActiveProposalQueue(endTime time.Time, proposalID int64)
- func (mapper Mapper) RemoveFromInactiveProposalQueue(endTime time.Time, proposalID int64)
- func (mapper Mapper) SetDeposit(proposalID int64, depositorAddr btypes.AccAddress, deposit types.Deposit)
- func (mapper Mapper) SetInitialProposalID(proposalID int64) btypes.Error
- func (mapper Mapper) SetParams(ctx context.Context, p types.Params)
- func (mapper Mapper) SetProposal(proposal types.Proposal)
- func (mapper *Mapper) SetUpMetrics(cfg *config.InstrumentationConfig)
- func (mapper Mapper) SetVote(proposalID int64, voterAddr btypes.AccAddress, vote types.Vote)
- func (mapper Mapper) SubmitProposal(ctx context.Context, content types.ProposalContent) (proposal types.Proposal, err btypes.Error)
- type Metrics
- type QueryProposalsParam
Constants ¶
const ( MetricsSubsystem = "gov" // metrics module name VoterLabel = "voter" // voter address ProposalIdLabel = "proposal" // proposal id OptionLabel = "option" // vote option )
const ( GOV = "gov" Proposals = "proposals" Proposal = "proposal" Votes = "votes" Vote = "vote" Deposits = "deposits" Deposit = "deposit" TallyQuery = "tally" ParamsPath = "params" )
nolint
const (
MapperName = "governance"
)
Variables ¶
This section is empty.
Functions ¶
func BuildQueryDepositPath ¶
nolint
func DepositInvariant ¶
func Query ¶
func Query(ctx context.Context, route []string, req abci.RequestQuery) (res []byte, err btypes.Error)
nolint
func Tally ¶
func Tally(ctx context.Context, mapper *Mapper, proposal gtypes.Proposal) (passes gtypes.ProposalResult, tallyResults gtypes.TallyResult, validators map[string]bool, deductOption gtypes.DeductOption)
统计投票信息,返回提议结果,投票结果,投票验证节点集合以及质押处理类型
Types ¶
type Mapper ¶
type Mapper struct { *mapper.BaseMapper Metrics *Metrics }
func (Mapper) ActiveProposalQueueIterator ¶
Returns an iterator for all the proposals in the Active Queue that expire by endTime
func (Mapper) AddDeposit ¶
func (mapper Mapper) AddDeposit(ctx context.Context, proposalID int64, depositorAddr btypes.AccAddress, depositAmount btypes.BigInt) (btypes.Error, bool)
Adds or updates a deposit of a specific depositor on a specific proposal Activates voting period when appropriate
func (Mapper) AddVote ¶
func (mapper Mapper) AddVote(proposalID int64, voterAddr btypes.AccAddress, option types.VoteOption) btypes.Error
Adds a vote on a specific proposal
func (Mapper) DeleteDeposits ¶
Deletes all the deposits on a specific proposal without refunding them
func (Mapper) DeleteProposal ¶
Delete proposal
func (Mapper) DeleteValidatorSet ¶
func (Mapper) ExistsUnfinishedProposals ¶ added in v0.0.8
func (mapper Mapper) ExistsUnfinishedProposals(ctx context.Context, proposalType types.ProposalType) bool
exists unfinished proposals
func (Mapper) GetDeposit ¶
func (mapper Mapper) GetDeposit(proposalID int64, depositorAddr btypes.AccAddress) (deposit types.Deposit, exists bool)
Gets the deposit of a specific depositor on a specific proposal
func (Mapper) GetDeposits ¶
Gets all the deposits on a specific proposal as an sdk.Iterator
func (Mapper) GetLastProposalID ¶
Get the last used proposal ID
func (Mapper) GetLevelParams ¶ added in v0.0.8
func (mapper Mapper) GetLevelParams(ctx context.Context, level types.ProposalLevel) types.LevelParams
func (Mapper) GetProposal ¶
Get Proposal from store by ProposalID
func (Mapper) GetProposals ¶
func (Mapper) GetProposalsFiltered ¶
func (mapper Mapper) GetProposalsFiltered(ctx context.Context, voterAddr, depositorAddr btypes.AccAddress, status types.ProposalStatus, numLatest int64) []types.Proposal
Get Proposal from store by ProposalID voterAddr will filter proposals by whether or not that address has voted on them depositorAddr will filter proposals by whether or not that address has deposited to them status will filter proposals by status numLatest will fetch a specified number of the most recent proposals, or 0 for all proposals
func (Mapper) GetValidatorSet ¶
func (mapper Mapper) GetValidatorSet(proposalID int64) (validators []btypes.ValAddress, exists bool)
func (Mapper) GetVote ¶
func (mapper Mapper) GetVote(proposalID int64, voterAddr btypes.AccAddress) (vote types.Vote, exists bool)
Gets the vote of a specific voter on a specific proposal
func (Mapper) InactiveProposalQueueIterator ¶
Returns an iterator for all the proposals in the Inactive Queue that expire by endTime
func (Mapper) InsertActiveProposalQueue ¶
Inserts a ProposalID into the active proposal queue at endTime
func (Mapper) InsertInactiveProposalQueue ¶
Inserts a ProposalID into the inactive proposal queue at endTime
func (Mapper) PeekCurrentProposalID ¶
Peeks the next available ProposalID without incrementing it
func (Mapper) RefundDeposits ¶
func (mapper Mapper) RefundDeposits(ctx context.Context, proposalID int64, level types.ProposalLevel, deductDeposit bool)
Refunds and deletes all the deposits on a specific proposal
func (Mapper) RemoveFromActiveProposalQueue ¶
removes a proposalID from the Active Proposal Queue
func (Mapper) RemoveFromInactiveProposalQueue ¶
removes a proposalID from the Inactive Proposal Queue
func (Mapper) SetDeposit ¶
func (Mapper) SetInitialProposalID ¶
Set the initial proposal ID
func (Mapper) SetProposal ¶
Update proposal
func (*Mapper) SetUpMetrics ¶ added in v0.0.8
func (mapper *Mapper) SetUpMetrics(cfg *config.InstrumentationConfig)
设置prometheus监控项
type Metrics ¶ added in v0.0.8
type Metrics struct { ProposalStatus metrics.Gauge // StatusNil:0 StatusDepositPeriod:1 StatusVotingPeriod:2 StatusPassed:3 StatusRejected:4 Vote metrics.Gauge // Total power of the voting delegations }
func NopMetrics ¶ added in v0.0.8
func NopMetrics() *Metrics
func PrometheusMetrics ¶ added in v0.0.8
func PrometheusMetrics(cfg *config.InstrumentationConfig) *Metrics
type QueryProposalsParam ¶
type QueryProposalsParam struct { Depositor btypes.AccAddress `json:"depositor"` Voter btypes.AccAddress `json:"voter"` Status types.ProposalStatus `json:"status"` Limit int64 `json:"limit"` }
nolint