mapper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MetricsSubsystem = "gov"      // metrics module name
	VoterLabel       = "voter"    // voter address
	ProposalIdLabel  = "proposal" // proposal id
	OptionLabel      = "option"   // vote option
)
View Source
const (
	GOV        = "gov"
	Proposals  = "proposals"
	Proposal   = "proposal"
	Votes      = "votes"
	Vote       = "vote"
	Deposits   = "deposits"
	Deposit    = "deposit"
	TallyQuery = "tally"
	ParamsPath = "params"
)

nolint

View Source
const (
	MapperName = "governance"
)

Variables

This section is empty.

Functions

func BuildQueryDepositPath

func BuildQueryDepositPath(pid int64, depositAddr string) string

nolint

func BuildQueryDepositsPath

func BuildQueryDepositsPath(pid int64) string

nolint

func BuildQueryModuleParamsPath

func BuildQueryModuleParamsPath(module string) string

nolint

func BuildQueryParamPath

func BuildQueryParamPath(module string, key string) string

nolint

func BuildQueryParamsPath

func BuildQueryParamsPath() string

nolint

func BuildQueryProposalPath

func BuildQueryProposalPath(pid int64) string

nolint

func BuildQueryProposalsPath

func BuildQueryProposalsPath() string

nolint

func BuildQueryTallyPath

func BuildQueryTallyPath(pid int64) string

nolint

func BuildQueryVotePath

func BuildQueryVotePath(pid int64, voterAddr string) string

nolint

func BuildQueryVotesPath

func BuildQueryVotesPath(pid int64) string

nolint

func DepositInvariant

func DepositInvariant(module string) qtypes.Invariant

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 GetMapper

func GetMapper(ctx context.Context) *Mapper

func NewMapper

func NewMapper() *Mapper

func (Mapper) ActiveProposalQueueIterator

func (mapper Mapper) ActiveProposalQueueIterator(endTime time.Time) store.Iterator

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

func (mapper *Mapper) Copy() mapper.IMapper

func (Mapper) DeleteDeposits

func (mapper Mapper) DeleteDeposits(ctx context.Context, proposalID int64)

Deletes all the deposits on a specific proposal without refunding them

func (Mapper) DeleteProposal

func (mapper Mapper) DeleteProposal(proposalID int64)

Delete proposal

func (Mapper) DeleteValidatorSet

func (mapper Mapper) DeleteValidatorSet(proposalID int64)

func (Mapper) DeleteVotes

func (mapper Mapper) DeleteVotes(proposalID int64)

Delete votes

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

func (mapper Mapper) GetDeposits(proposalID int64) store.Iterator

Gets all the deposits on a specific proposal as an sdk.Iterator

func (Mapper) GetLastProposalID

func (mapper Mapper) GetLastProposalID() (proposalID int64)

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

func (mapper Mapper) GetParams(ctx context.Context) types.Params

func (Mapper) GetProposal

func (mapper Mapper) GetProposal(proposalID int64) (proposal types.Proposal, ok bool)

Get Proposal from store by ProposalID

func (Mapper) GetProposals

func (mapper Mapper) GetProposals() []types.Proposal

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

func (mapper Mapper) GetVotes(proposalID int64) store.Iterator

Gets all the votes on a specific proposal

func (Mapper) InactiveProposalQueueIterator

func (mapper Mapper) InactiveProposalQueueIterator(endTime time.Time) store.Iterator

Returns an iterator for all the proposals in the Inactive Queue that expire by endTime

func (Mapper) InsertActiveProposalQueue

func (mapper Mapper) InsertActiveProposalQueue(endTime time.Time, proposalID int64)

Inserts a ProposalID into the active proposal queue at endTime

func (Mapper) InsertInactiveProposalQueue

func (mapper Mapper) InsertInactiveProposalQueue(endTime time.Time, proposalID int64)

Inserts a ProposalID into the inactive proposal queue at endTime

func (Mapper) PeekCurrentProposalID

func (mapper Mapper) PeekCurrentProposalID() (proposalID int64, err btypes.Error)

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

func (mapper Mapper) RemoveFromActiveProposalQueue(endTime time.Time, proposalID int64)

removes a proposalID from the Active Proposal Queue

func (Mapper) RemoveFromInactiveProposalQueue

func (mapper Mapper) RemoveFromInactiveProposalQueue(endTime time.Time, proposalID int64)

removes a proposalID from the Inactive Proposal Queue

func (Mapper) SetDeposit

func (mapper Mapper) SetDeposit(proposalID int64, depositorAddr btypes.AccAddress, deposit types.Deposit)

func (Mapper) SetInitialProposalID

func (mapper Mapper) SetInitialProposalID(proposalID int64) btypes.Error

Set the initial proposal ID

func (Mapper) SetParams

func (mapper Mapper) SetParams(ctx context.Context, p types.Params)

func (Mapper) SetProposal

func (mapper Mapper) SetProposal(proposal types.Proposal)

Update proposal

func (*Mapper) SetUpMetrics added in v0.0.8

func (mapper *Mapper) SetUpMetrics(cfg *config.InstrumentationConfig)

设置prometheus监控项

func (Mapper) SetVote

func (mapper Mapper) SetVote(proposalID int64, voterAddr btypes.AccAddress, vote types.Vote)

func (Mapper) SubmitProposal

func (mapper Mapper) SubmitProposal(ctx context.Context, content types.ProposalContent) (proposal types.Proposal, err btypes.Error)

Submit proposal

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

Jump to

Keyboard shortcuts

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