utils

package
v0.1.4-beta Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommitSeconds       = 10
	HalfYear            = 180
	YearlyBlockNumber   = 365 * 24 * 3600 / CommitSeconds
	BasicMintableAmount = "1000000000000000000000000000"
	DB_FILE_NAME        = "cybermiles.db"
)
View Source
const (
	Staging      = 20
	TestNet      = 19
	MainNet      = 18
	PrivateChain = 1234
)
View Source
const (
	MonitorRpcPort = "26650"
)

Variables

View Source
var (
	BlockGasFee      = big.NewInt(0)
	StateChangeQueue []StateChangeObject
	PendingProposal  = &pendingProposal{
		make(map[string]int64),
		math.MaxInt64,
		nil,
		make(map[string]int64),
		math.MaxInt64,
		nil,
	}
	RetiringProposalId string // Indicate where to shutdown the node

	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
	AbsentValidatorsKey    = []byte{0x03} // key for absent validators
	ToBeReplacedPubKeysKey = []byte{0x04} // key for absent validators

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

func Contains(slice []string, item string) bool

func ConvertDaysToHeight

func ConvertDaysToHeight(days int64) int64

func Diff

func Diff(t string) (int64, error)

func FormatUnixTime

func FormatUnixTime(ts int64) string

func GetNow

func GetNow() string

func GetTimeBefore

func GetTimeBefore(ts int64, hours int) (string, error)

func GetTimeBeforeNow

func GetTimeBeforeNow(hours int) (string, error)

func IsBlank

func IsBlank(str string) bool

func IsEmptyAddress

func IsEmptyAddress(address common.Address) bool

func IsEthTx

func IsEthTx(tx *types.Transaction) bool

func LeftPad

func LeftPad(str string, count int) string

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"`
	DeclareCandidacyGas                    uint64  `json:"declare_candidacy_gas" type:"uint"`
	UpdateCandidacyGas                     uint64  `json:"update_candidacy_gas" type:"uint"`
	SetCompRateGas                         uint64  `json:"set_comp_rate_gas" type:"uint"`
	UpdateCandidateAccountGas              uint64  `json:"update_candidate_account_gas" type:"uint"`
	AcceptCandidateAccountUpdateRequestGas uint64  `json:"accept_candidate_account_update_request_gas" type:"uint"`
	TransferFundProposalGas                uint64  `json:"transfer_fund_proposal_gas" type:"uint"`
	ChangeParamsProposalGas                uint64  `json:"change_params_proposal_gas" type:"uint"`
	DeployLibEniProposalGas                uint64  `json:"deploy_libeni_proposal_gas" type:"uint"`
	RetireProgramProposalGas               uint64  `json:"retire_program_proposal_gas" type:"uint"`
	UpgradeProgramProposalGas              uint64  `json:"upgrade_program_proposal_gas" 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"`
	MaxSlashBlocks                         int16   `json:"max_slash_blocks" type:"uint"`
	SlashRatio                             sdk.Rat `json:"slash_ratio" type:"rat"`
	SlashEnabled                           bool    `json:"slash_enabled" type:"bool"`
	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"`
	FoundationAddress                      string  `json:"foundation_address"`
	CalStakeInterval                       uint64  `json:"cal_stake_interval" type:"uint"`
	CalVPInterval                          uint64  `json:"cal_vp_interval" type:"uint"`
	CalAverageStakingDateInterval          uint64  `json:"cal_avg_staking_date_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