common

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//node type
	NodeType = nodeTypeNormal

	//DPOS params
	DPoSMaxBlocks      = 102400
	DPoSMaxCacheBlocks = 102400
	DPoSVoteCacheEn    = true

	//EventBus params
	EventBusWaitingQueueSize = 102400

	//Consensus params
	ConsensusMsgCacheSize = 102400

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

	//P2P params
	P2PMsgChanSize         = 655350
	P2PMsgCacheSize        = 51200
	P2PMonitorMsgChanSize  = 65535
	P2PMonitorMsgCacheSize = 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 / 30)
	PovMinerRewardPerBlockInt     = big.NewInt(285388127)
	PovMinerRewardPerBlockBalance = types.NewBalance(285388127)

	PoVMaxForkHeight = uint64(POVChainBlocksPerHour * 12)

	PovGenesisTargetHex = "" /* 128-byte string literal not displayed */

	PovGenesisTargetInt, _ = new(big.Int).SetString(PovGenesisTargetHex, 16)

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

	PovMaxNonce = ^uint64(0) // 2^64 - 1
)
View Source
var (
	//vote right divisor
	DposVoteDivisor = int64(200)
)

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 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 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 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 SyncState added in v1.2.3

type SyncState uint

Sync state

const (
	SyncNotStart SyncState = iota
	Syncing
	Syncdone
	Syncerr
)

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"
	EventSyncing           TopicType = "syncing"
	EventAddRelation       TopicType = "addRelation"
	EventDeleteRelation    TopicType = "deleteRelation"
	EventGenerateBlock     TopicType = "generateBlock"
	EventRollbackUnchecked TopicType = "rollbackUnchecked"

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

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