utils

package
v0.1.0-rc.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommitSeconds = 10
	// calculate candidate stakes interval
	DefaultCalStateInterval = 1
	// calculate voting power interval
	DefaultCalVPInterval = 1
	HalfYear             = 180
	YearlyBlockNumber    = 365 * 24 * 3600 / 10
	BasicMintableAmount  = "1000000000000000000000000000"
)

Variables

View Source
var (
	BlockGasFee      = big.NewInt(0)
	StateChangeQueue []StateChangeObject
	// Recording addresses associated with travis tx (stake/governance) in one block
	// Transfer transaction is not allowed if the sender of which was found in this recording
	// TODO to be removed
	TravisTxAddrs   []*common.Address
	PendingProposal = &pendingProposal{
		make(map[string]int64),
		math.MaxInt64,
		nil,
		make(map[string]int64),
		math.MaxInt64,
		nil,
	}
	MintAccount    = common.HexToAddress("0000000000000000000000000000000000000000")
	HoldAccount    = common.HexToAddress("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
	GovHoldAccount = common.HexToAddress("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
)
View Source
var (
	// Keys for store prefixes
	ParamKey      = []byte{0x01} // key for global parameters
	AwardInfosKey = []byte{0x02} // key for award infos

)
View Source
var GOOSDIST string
View Source
var GOOSVERS string
View Source
var SUPPORT_OS = map[string][]string{
	"ubuntu": {"16.04"},
	"centos": {"^7.0"},
}

Functions

func CalGasFee

func CalGasFee(gasUsed uint64, gasPrice uint64) sdk.Int

func CheckParamType

func CheckParamType(name, value string) bool

func CleanParams

func CleanParams() (before bool)

func Diff

func Diff(t string) (int64, error)

func GetCalStakeInterval

func GetCalStakeInterval() int64

GetCalStakeInterval helper function of getting calculate stake interval

func GetCalVPInterval

func GetCalVPInterval() int64

GetCalStakeInterval helper function of getting calculate stake interval

func GetNow

func GetNow() string

func GetTimeBefore

func GetTimeBefore(hours int) (string, error)

func IsEthTx

func IsEthTx(tx *types.Transaction) bool

func LoadParams

func LoadParams(b []byte)

load/save the global params

func ParseFloat

func ParseFloat(str string) float64

func ParseInt

func ParseInt(str string) sdk.Int

func RoundFloat

func RoundFloat(f float64, n int) float64

func SetParam

func SetParam(name, value string) bool

func SetParams

func SetParams(p *Params)

func ToWei

func ToWei(value int64) (result *big.Int)

func UnloadParams

func UnloadParams() (b []byte)

Types

type Params

type Params struct {
	MaxVals                   uint16  `json:"max_vals" type:"uint"`    // maximum number of validators
	BackupVals                uint16  `json:"backup_vals" type:"uint"` // number of backup validators
	SelfStakingRatio          sdk.Rat `json:"self_staking_ratio" type:"rat"`
	InflationRate             sdk.Rat `json:"inflation_rate" type:"rat"`
	ValidatorSizeThreshold    sdk.Rat `json:"validator_size_threshold" type:"rat"`
	UnstakeWaitingPeriod      uint64  `json:"unstake_waiting_period" type:"uint"`
	ProposalExpirePeriod      uint64  `json:"proposal_expire_period" type:"uint"`
	DeclareCandidacy          uint64  `json:"declare_candidacy" type:"uint"`
	UpdateCandidacy           uint64  `json:"update_candidacy" type:"uint"`
	TransferFundProposal      uint64  `json:"transfer_fund_proposal" type:"uint"`
	ChangeParamsProposal      uint64  `json:"change_params_proposal" type:"uint"`
	DeployLibEniProposal      uint64  `json:"deploy_libeni_proposal" type:"uint"`
	GasPrice                  uint64  `json:"gas_price" type:"uint"`
	MinStakingAmount          int64   `json:"min_staking_amount" type:"uint"`
	ValidatorsBlockAwardRatio sdk.Rat `json:"validators_block_award_ratio" type:"rat"`
	MaxSlashingBlocks         int16   `json:"max_slashing_blocks" type:"uint"`
	SlashingRatio             sdk.Rat `json:"slashing_ratio" type:"rat"`
	CubePubKeys               string  `json:"cube_pub_keys" type:"json"`
	LowPriceTxGasLimit        uint64  `json:"low_price_tx_gas_limit" type:"uint"`
	LowPriceTxSlotsCap        int     `json:"low_price_tx_slots_cap" type:"int"`
	SetCompRate               uint64  `json:"set_comp_rate" type:"uint"`
	FoundationAddress         string  `json:"foundation_address"`
	CalStakeInterval          uint64  `json:"cal_stake_interval" type:"uint"`
	CalVPInterval             uint64  `json:"cal_vp_interval" type:"uint"`
}

func DefaultParams

func DefaultParams() *Params

func GetParams

func GetParams() *Params

type StateChangeObject

type StateChangeObject struct {
	From   common.Address
	To     common.Address
	Amount sdk.Int

	Reactor StateChangeReactor
}

type StateChangeReactor

type StateChangeReactor interface {
	React(result, msg string)
}

Jump to

Keyboard shortcuts

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