utils

package
v0.0.0-...-56f3d1a Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 10

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"
	ChainConfigKernelContract = "$chainConfig"
)
View Source
const (
	StatusOK        = 200
	StatusException = 500
)

Variables

This section is empty.

Functions

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 GetUpdateGasPriceMethod

func GetUpdateGasPriceMethod() string

func GetUpdateMaxBlockSizeMethod

func GetUpdateMaxBlockSizeMethod() string

func MakeAccountBalanceKey

func MakeAccountBalanceKey(account string) string

MakeContractMethodKey generate contract and account mapping key

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