common

package
v1.4.1-beta Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OracleTypeEmail uint32 = iota
	OracleTypeWeChat
	OracleTypeInvalid
)
View Source
const (
	OracleExpirePovHeight  = 10
	OracleVerifyMinAccount = 3
	OracleVerifyMaxAccount = 5
)
View Source
const (
	VerifierMinNum = 1
	VerifierMaxNum = 5
)
View Source
const (
	PublicKeyTypeED25519 uint16 = iota
	PublicKeyTypeRSA4096
	PublicKeyTypeInvalid
)
View Source
const (
	PtmKeyVBtypeDefault uint16 = iota
	PtmKeyVBtypeA2p
	PtmKeyVBtypeDod
	PtmKeyVBtypeCloud
	PtmKeyVBtypeInvaild
)
View Source
const (
	PtmKeyVBtypeStrDefault = "default"
	PtmKeyVBtypeStrA2p     = "a2p"
	PtmKeyVBtypeStrDod     = "dod"
	PtmKeyVBtypeStrCloud   = "cloud"
	PtmKeyVBtypeStrInvaild = "invalid"
)
View Source
const (
	RpcDPoSOnSyncStateChange uint = iota
	RpcDPoSProcessFrontier
	RpcDPoSConsInfo
	RpcDPoSOnlineInfo
	RpcDPoSSetConsPerf
	RpcDPoSGetConsPerf
	RpcDPoSFeed
	RpcDPoSDebug
)
View Source
const (
	//vote right divisor
	DposVoteDivisor = int64(200)

	DPosOnlinePeriod        = uint64(120)
	DPosOnlineRate          = uint64(60)
	DPosHeartCountPerPeriod = DPosOnlinePeriod / 2
	DPosOnlineSectionLeft   = 30
	DPosOnlineSectionRight  = 90
)
View Source
const (
	SyncCacheUnchecked byte = iota
	SyncCacheUnconfirmed
)
View Source
const RandomCodeLen = 16

Variables

View Source
var (
	MinVerifierPledgeAmount = types.NewBalance(3e+14) // 3M
	OracleCost              = types.NewBalance(1e+7)  // 0.1
	PublishCost             = types.NewBalance(5e+8)  // 5
)
View Source
var (
	//node type
	NodeType = nodeTypeNormal

	//DPOS params
	DPoSMaxBlocks      = 102400
	DPoSMaxCacheBlocks = 102400

	//EventBus params
	EventBusWaitingQueueSize = 102400

	//Badger params
	BadgerMaxTableSize = int64(64 << 20)

	//P2P params
	P2PMsgChanSize        = 655350
	P2PMsgCacheSize       = 51200
	P2PMonitorMsgChanSize = 65535
)
View Source
var (
	// PoV Block Chain Params
	PovChainGenesisBlockHeight = uint64(0)

	PovChainBlockInterval = 60
	PovChainTargetCycle   = 20
	PovChainBlockSize     = 2 * 1024 * 1024

	PovChainRetargetTimespan    = PovChainBlockInterval * PovChainTargetCycle
	PovChainMinRetargetTimespan = PovChainRetargetTimespan / 4
	PovChainMaxRetargetTimespan = PovChainRetargetTimespan * 4

	POVChainBlocksPerHour = 3600 / PovChainBlockInterval
	POVChainBlocksPerDay  = POVChainBlocksPerHour * 24

	// Miner core parameters
	PovMinerPledgeAmountMin         = types.NewBalance(10000000000000)
	PovMinerVerifyHeightStart       = uint64(POVChainBlocksPerDay * 1)
	PovMinerRewardHeightStart       = uint64(POVChainBlocksPerDay * 1)
	PovMinerRewardHeightGapToLatest = uint64(POVChainBlocksPerDay * 1)
	PovMinerMaxRewardBlocksPerCall  = uint64(POVChainBlocksPerDay * 7)
	PovMinerRewardHeightRound       = uint64(POVChainBlocksPerDay * 1)
	PovMinerMaxFindNonceTimeSec     = PovChainBlockInterval * PovChainTargetCycle

	// Reward per block, rewardPerBlock * blockNumPerYear / gasTotalSupply = 3%
	// 10000000000000000 * 0.03 / (365 * 24 * 60)
	PovMinerRewardPerDay          = uint64(821917808219)
	PovMinerRewardPerBlock        = uint64(570776255)
	PovMinerRewardPerBlockInt     = big.NewInt(int64(PovMinerRewardPerBlock))
	PovMinerRewardPerBlockBalance = types.NewBalance(int64(PovMinerRewardPerBlock))
	PovMinerMinRewardPerBlock     = uint64(570776) // 0.001 * 570776255
	PovMinerRewardRatioMiner      = 60             // 60%
	PovMinerRewardRatioRep        = 40             // 40%

	// Bonus per block, bonusPerBlock * blockNumPerYear / stakingRewardPerYear = 90%(max)
	PovStakingRewardPerDay     = uint64(830200000000)
	PovMinerBonusMaxPerDay     = uint64(747180000000) // 830200000000 * 90 / 100
	PovMinerBonusPerKiloPerDay = uint64(747180)       // 747180000000 / (1G / 1M)
	PovMinerBonusDiffRatioMax  = uint64(1000000000)   // 1G
	PovMinerBonusDiffRatioMin  = 1000                 // 1K

	PoVMaxForkHeight = uint64(POVChainBlocksPerHour * 23)

	PovGenesisPowHex    = "00000000ffff0000000000000000000000000000000000000000000000000000"
	PovGenesisPowInt, _ = new(big.Int).SetString(PovGenesisPowHex, 16)
	PovGenesisPowBits   = types.BigToCompact(PovGenesisPowInt) //0x1d00ffff

	// PowLimit is the highest proof of work value a Bitcoin block
	// can have for the test network.
	PovPowLimitHex    = "00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
	PovPowLimitInt, _ = new(big.Int).SetString(PovPowLimitHex, 16)
	PovPowLimitBits   = types.BigToCompact(PovPowLimitInt) //0x1d00ffff

	// maximum number of seconds a block time is allowed to be ahead of the now time.
	PovMaxAllowedFutureTimeSec = 300

	PovMinCoinbaseExtraSize = 2
	PovMaxCoinbaseExtraSize = 100
)

Functions

func BalanceToRaw added in v0.0.9

func BalanceToRaw(b types.Balance, unit string) (types.Balance, error)

func GenesisPovBlock added in v1.2.3

func GenesisPovBlock() types.PovBlock

func GenesisPovStateKVs added in v1.2.3

func GenesisPovStateKVs() (keys [][]byte, values [][]byte)

func Go added in v1.2.3

func Go(fn func())

func IsConfidantNode added in v1.2.3

func IsConfidantNode() bool

func IsGenesisPovBlock added in v1.2.3

func IsGenesisPovBlock(block *types.PovBlock) bool

func IsNormalNode added in v1.2.3

func IsNormalNode() bool

func OracleStringToType added in v1.4.0

func OracleStringToType(os string) uint32

func OracleTypeToString added in v1.4.0

func OracleTypeToString(ot uint32) string

func PovIsAlgoSupported added in v1.4.0

func PovIsAlgoSupported(algoType types.PovAlgoType) bool

func PtmKeyBtypeFromString added in v1.4.0

func PtmKeyBtypeFromString(t string) uint16

func PtmKeyBtypeToString added in v1.4.0

func PtmKeyBtypeToString(t uint16) string

func PublicKeyTypeFromString added in v1.4.0

func PublicKeyTypeFromString(t string) uint16

func PublicKeyTypeToString added in v1.4.0

func PublicKeyTypeToString(t uint16) string

func PublicKeyWithTypeHash added in v1.4.0

func PublicKeyWithTypeHash(t uint16, k []byte) []byte

func RawToBalance added in v0.0.9

func RawToBalance(b types.Balance, unit string) (types.Balance, error)

func RawToBalanceFloat added in v1.2.3

func RawToBalanceFloat(b types.Balance, unit string) (*big.Float, error)

func TimeNow added in v1.1.0

func TimeNow() time.Time

Types

type ContractGapType added in v1.4.0

type ContractGapType byte
const (
	ContractNoGap ContractGapType = iota
	ContractRewardGapPov
	ContractDPKIGapPublish
	ContractPermGapAdmin
	ContractDoDOrderState
)

type InterceptCall added in v1.4.0

type InterceptCall interface {
	RpcCall(kind uint, in, out interface{})
}

type Service

type Service interface {
	Init() error
	Start() error
	Stop() error
	Status() int32
}

Service action and status

type ServiceLifecycle

type ServiceLifecycle struct {
	Status int32 // ServiceStatus
}

func (*ServiceLifecycle) PostInit

func (s *ServiceLifecycle) PostInit() bool

func (*ServiceLifecycle) PostStart

func (s *ServiceLifecycle) PostStart() bool

func (*ServiceLifecycle) PostStop

func (s *ServiceLifecycle) PostStop() bool

func (*ServiceLifecycle) PreInit

func (s *ServiceLifecycle) PreInit() bool

func (*ServiceLifecycle) PreStart

func (s *ServiceLifecycle) PreStart() bool

func (*ServiceLifecycle) PreStop

func (s *ServiceLifecycle) PreStop() bool

func (*ServiceLifecycle) Reset added in v1.4.0

func (s *ServiceLifecycle) Reset() bool

func (*ServiceLifecycle) State

func (s *ServiceLifecycle) State() int32

func (*ServiceLifecycle) Stopped

func (s *ServiceLifecycle) Stopped() bool

func (*ServiceLifecycle) String

func (s *ServiceLifecycle) String() string

type ServiceStatus

type ServiceStatus int32
const (
	Origin ServiceStatus = iota
	Initialing
	Inited
	Starting
	Started
	Stopping
	Stopped
)

func (ServiceStatus) String

func (i ServiceStatus) String() string

type SyncCacheWalkFunc added in v1.3.0

type SyncCacheWalkFunc func(kind byte, key []byte)

Directories

Path Synopsis
db
Package common contains various helper functions.
Package common contains various helper functions.
hexutil
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
vmcontract

Jump to

Keyboard shortcuts

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