utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GovernTokenTypeOrdinary = "ordinary"
	GovernTokenTypeTDPOS    = "tdpos"

	ProposalStatusVoting              = "voting"
	ProposalStatusCancelled           = "cancelled"
	ProposalStatusRejected            = "rejected"
	ProposalStatusPassed              = "passed"
	ProposalStatusCompletedAndFailure = "completed_failure"
	ProposalStatusCompletedAndSuccess = "completed_success"
)
View Source
const (
	GovernTokenKernelContract = "$govern_token"
	ProposalKernelContract    = "$proposal"
	TimerTaskKernelContract   = "$timer_task"
	TDPOSKernelContract       = "$tdpos"
	XPOSKernelContract        = "$xpos"
)
View Source
const (
	StatusOK        = 200
	StatusException = 500
)

Variables

This section is empty.

Functions

func GetCacheKey

func GetCacheKey() string

func GetDistributedKey

func GetDistributedKey() string

GetDistributedKey get contract distributed key

func GetGovernTokenBucket

func GetGovernTokenBucket() string

GetGovernTokenBucket return the govern token bucket name

func GetProposalBucket

func GetProposalBucket() string

GetProposalBucket return the proposal bucket name

func GetProposalIDKey

func GetProposalIDKey() []byte

GetProposalIDKey return the proposal_id key name

func GetTaskIDKey

func GetTaskIDKey() []byte

GetTaskIDKey return the task_id key name

func GetTimerBucket

func GetTimerBucket() string

GetTimerBucket return the balance bucket name

func GetvoteCandidateKey

func GetvoteCandidateKey() string

func MakeAccountBalanceKey

func MakeAccountBalanceKey(account string) string

MakeContractMethodKey generate contract and account mapping key

func MakeCacheKey

func MakeCacheKey(account string) string

func MakeProposalKey

func MakeProposalKey(proposalID string) string

MakeProposalKey generate proposal key

func MakeProposalLockKey

func MakeProposalLockKey(proposalID string, account string) string

MakeProposalLockKey generate proposal lock key

func MakeProposalLockPrefix

func MakeProposalLockPrefix(proposalID string) string

MakeTimerBlockHeightPrefix generate timer and blockHeight prefix

func MakeProposalLockPrefixSeparator

func MakeProposalLockPrefixSeparator(proposalID string) string

MakeTimerBlockHeightPrefix generate timer and blockHeight prefix

func MakeTimerBlockHeightPrefix

func MakeTimerBlockHeightPrefix(blockHeight string) string

MakeTimerBlockHeightPrefix generate timer and blockHeight prefix

func MakeTimerBlockHeightPrefixSeparator

func MakeTimerBlockHeightPrefixSeparator(blockHeight string) string

MakeTimerBlockHeightPrefix generate timer and blockHeight prefix

func MakeTimerBlockHeightTaskKey

func MakeTimerBlockHeightTaskKey(blockHeight string, taskID string) string

MakeTimerBlockHeightKey generate timer and blockHeight mapping key

func MakeTotalSupplyKey

func MakeTotalSupplyKey() string

MakeTotalSupplyKey generate totalsupply key

func MakevoteCandidateKey

func MakevoteCandidateKey(account string) string

func PrefixRange

func PrefixRange(prefix []byte) []byte

PrefixRange returns key range that satisfy the given prefix

func UnParse

func UnParse(proposal *Proposal) ([]byte, error)

UnParse

Types

type AllCandidate

type AllCandidate struct {
	Candidate map[string]string `json:"candidate"`
}

纪录所有提名人,每轮开始的时候用于更新缓存表

type CacheVoteCandidate

type CacheVoteCandidate struct {
	//分红比率
	Ratio int64 `json:"ratio"`
	//投票的人
	VotingUser map[string]*big.Int `json:"voting_user"`
	//总票数
	TotalVote *big.Int `json:"total_vote"`
}

缓存表,产块分红读取这个

type CandidateRatio

type CandidateRatio struct {
	//总票数
	TotalVote *big.Int `json:"total_vote"`
	//分红比率
	Ratio int64 `json:"ratio"`
	//投票的人
	VotingUser map[string]*big.Int `json:"voting_user"`
	//是否是提名人(取消此提名人后数据不能删除,通过标志位修改)
	IsNominate bool `json:"is_nominate"`
	//我投票的人
	MyVoting map[string]*big.Int `json:"my_voting"`
}

投票提名记录表(普通用户这是这张表,只是部分数据没有而已)

func NewCandidateRatio

func NewCandidateRatio() *CandidateRatio

type GovernTokenBalance

type GovernTokenBalance struct {
	TotalBalance  *big.Int            `json:"total_balance"`
	LockedBalance map[string]*big.Int `json:"locked_balances"`
}

Govern Token Balance TotalBalance = AvailableBalance + LockedBalance 目前包括tdpos和oridinary两种场景 用户的可转账余额是min(AvailableBalances)

func NewGovernTokenBalance

func NewGovernTokenBalance() *GovernTokenBalance

type Proposal

type Proposal struct {
	Args    map[string]interface{} `json:"args"`
	Trigger *TriggerDesc           `json:"trigger"`

	VoteAmount *big.Int `json:"vote_amount"`
	Status     string   `json:"status"`
	Proposer   string   `json:"proposer"`
}

Proposal

func Parse

func Parse(proposalStr string) (*Proposal, error)

Parse

type TriggerDesc

type TriggerDesc struct {
	Height   int64                  `json:"height"`
	Module   string                 `json:"module"`
	Contract string                 `json:"contract"`
	Method   string                 `json:"method"`
	Args     map[string]interface{} `json:"args"`
}

TriggerDesc is the description to trigger a event used by proposal

Jump to

Keyboard shortcuts

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