common

package
v1.3.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

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
)

Variables

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

	PovMinerPledgeAmountMin         = types.NewBalance(100000000000000)
	PovMinerVerifyHeightStart       = uint64(POVChainBlocksPerDay * 1)
	PovMinerRewardHeightStart       = uint64(POVChainBlocksPerDay * 30)
	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 / (3600 * 24 * 365 / 60)
	PovMinerRewardPerBlock        = 570776255
	PovMinerRewardPerBlockInt     = big.NewInt(int64(PovMinerRewardPerBlock))
	PovMinerRewardPerBlockBalance = types.NewBalance(int64(PovMinerRewardPerBlock))
	PovMinerMinRewardPerBlock     = 570776 // 0.001 * 570776255
	PovMinerRewardRatioMiner      = 80     // 80%
	PovMinerRewardRatioRep        = 20     // 20%

	PoVMaxForkHeight = uint64(POVChainBlocksPerHour * 12)

	PovGenesisPowHex    = "00000ffff0000000000000000000000000000000000000000000000000000000"
	PovGenesisPowInt, _ = new(big.Int).SetString(PovGenesisPowHex, 16)
	PovGenesisPowBits   = types.BigToCompact(PovGenesisPowInt) //0x1e0ffff0

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

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

	PovMaxNonce = ^uint32(0) // 2^32 - 1

	PovMinCoinbaseExtraSize = 2
	PovMaxCoinbaseExtraSize = 100
)

Functions

func AllGenesisBlocks added in v1.2.3

func AllGenesisBlocks() []types.StateBlock

func BalanceToRaw added in v0.0.9

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

func ChainToken added in v1.0.1

func ChainToken() types.Hash

func CheckTestMode added in v1.3.0

func CheckTestMode(flag string) bool

func GasAddress added in v1.0.4

func GasAddress() types.Address

func GasBlock added in v1.0.4

func GasBlock() types.StateBlock

func GasBlockHash added in v1.0.4

func GasBlockHash() types.Hash

func GasMintageBlock added in v1.0.4

func GasMintageBlock() types.StateBlock

func GasMintageHash added in v1.0.4

func GasMintageHash() types.Hash

func GasToken added in v1.0.4

func GasToken() types.Hash

func GenesisAddress added in v1.0.1

func GenesisAddress() types.Address

func GenesisBlock added in v1.0.1

func GenesisBlock() types.StateBlock

func GenesisBlockHash added in v1.0.1

func GenesisBlockHash() types.Hash

func GenesisMintageBlock added in v0.0.9

func GenesisMintageBlock() types.StateBlock

func GenesisMintageHash added in v0.0.9

func GenesisMintageHash() types.Hash

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 GetTestMode added in v1.3.0

func GetTestMode() string

func Go added in v1.2.3

func Go(fn func())

func IsConfidantNode added in v1.2.3

func IsConfidantNode() bool

func IsGenesisBlock added in v0.0.9

func IsGenesisBlock(block *types.StateBlock) bool

IsGenesis check block is chain token genesis

func IsGenesisPovBlock added in v1.2.3

func IsGenesisPovBlock(block *types.PovBlock) bool

func IsGenesisToken added in v1.0.4

func IsGenesisToken(hash types.Hash) bool

IsGenesis check token is chain token genesis

func IsNormalNode added in v1.2.3

func IsNormalNode() bool

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 SetTestMode added in v1.3.0

func SetTestMode(mode string)

func TimeNow added in v1.1.0

func TimeNow() time.Time

Types

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

type SyncState added in v1.2.3

type SyncState uint

Sync state

const (
	SyncNotStart SyncState = iota
	Syncing
	SyncDone
	SyncFinish
)

func (SyncState) IsSyncExited added in v1.2.3

func (s SyncState) IsSyncExited() bool

func (SyncState) String added in v1.2.3

func (s SyncState) String() string

type TopicType added in v1.1.0

type TopicType string
const (
	EventPublish           TopicType = "publish"
	EventConfirmReq        TopicType = "confirmReq"
	EventConfirmAck        TopicType = "confirmAck"
	EventSyncBlock         TopicType = "syncBlock"
	EventConfirmedBlock    TopicType = "confirmedBlock"
	EventBroadcast         TopicType = "broadcast"
	EventSendMsgToPeers    TopicType = "sendMsgToPeers"
	EventPeersInfo         TopicType = "peersInfo"
	EventSyncStatus        TopicType = "syncing"
	EventGetBandwidthStats TopicType = "getBandwidthStats"
	EventAddRelation       TopicType = "addRelation"
	EventAddSyncBlocks     TopicType = "addSyncBlocks"
	EventDeleteRelation    TopicType = "deleteRelation"
	EventGenerateBlock     TopicType = "generateBlock"
	EventRollback          TopicType = "rollback"
	EventRestartChain      TopicType = "restartChain"

	EventSendMsgToSingle TopicType = "sendMsgToSingle"
	EventAddP2PStream    TopicType = "addP2PStream"
	EventDeleteP2PStream TopicType = "deleteP2PStream"
	EventPovPeerStatus   TopicType = "povPeerStatus"
	EventPovRecvBlock    TopicType = "povRecvBlock"
	EventPovBulkPullReq  TopicType = "povBulkPullReq"
	EventPovBulkPullRsp  TopicType = "povBulkPullRsp"
	EventPovSyncState    TopicType = "povSyncState"

	EventPovConnectBestBlock    TopicType = "povConnectBestBlock"
	EventPovDisconnectBestBlock TopicType = "povDisconnectBestBlock"
	EventRpcSyncCall            TopicType = "rpcSyncCall"
	EventFrontiersReq           TopicType = "FrontiersReq"
	EventFrontierConsensus      TopicType = "frontierConsensus"
	EventFrontierConfirmed      TopicType = "frontierConfirmed"
	EventSyncStateChange        TopicType = "syncStateChange"
	EventConsensusSyncFinished  TopicType = "consensusSyncFinished"
	EventRepresentativeNode     TopicType = "representativeNode"
)

Topic type

Directories

Path Synopsis
sync
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.

Jump to

Keyboard shortcuts

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