utils

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxbftQC defines the key in block.AdditionalData.ExtraData
	MaxbftQC = "maxbftQC"
	// BFTNodesNum The number of nodes required to support Byzantium
	BFTNodesNum = 4
)
View Source
const (
	// BlockVersion2400 启动随机交易剔除、支持单节点启动等新功能
	BlockVersion2400 = uint32(2040000)
)

不同的版本启用各种新功能

Variables

View Source
var (
	// MaxBFTAdditionalQCKey defines the key of qc in block.AdditionalData
	MaxBFTAdditionalQCKey = "MaxBFTAdditionalQCKey"

	// RoundTimeoutMill defines the key of view timeout in chainConf
	RoundTimeoutMill = strings.ToLower("MaxBFTRoundTimeoutMill")

	// RoundTimeoutIntervalMill defines the key of view increment timeout in chainConf
	RoundTimeoutIntervalMill = strings.ToLower("MaxBFTRoundTimeoutIntervalMill")

	// MaxTimeoutMill defines the key of the max view timeout in chainConf
	MaxTimeoutMill = strings.ToLower("MaxBFTMaxTimeoutMill")

	// EpochStrategy strategy of the epoch: BaseOnHeight, BaseOnView, Timely, NilEpoch
	EpochStrategy = strings.ToLower("MaxBFTEpochStrategy")
	// NumPerEpoch The number of blocks or views in per epoch.
	NumPerEpoch = strings.ToLower("MaxBFTPerEpochNumber")
	// ViewNumsPerEpochV230 view num in each epoch on v2.3.0 chainVersion
	ViewNumsPerEpochV230 = "MaxBftViewNumsPerEpoch"

	// DefaultRoundTimeout defines the default timeout in a view
	DefaultRoundTimeout time.Duration = 15000

	// DefaultRoundTimeoutInterval defines the default timeout increment in a view
	DefaultRoundTimeoutInterval time.Duration = 1000

	// DefaultMaxRoundTimeout defines the default max timeout in a view 1 min
	DefaultMaxRoundTimeout time.Duration = 1000 * 60
)

Functions

func AddArgsToBlock

func AddArgsToBlock(view uint64, block *common.Block, txRwSet *common.TxRWSet)

AddArgsToBlock adds txRwSet and view to the specified block

func GetBlockIdFromQC

func GetBlockIdFromQC(qc *maxbft.QuorumCert) []byte

GetBlockIdFromQC returns the block hash in the specified quorum certification

func GetBlockView

func GetBlockView(block *common.Block) uint64

GetBlockView returns the view of the specified block

func GetChainConfigFromChainStore

func GetChainConfigFromChainStore(store protocol.BlockchainStore) (*config.ChainConfig, error)

GetChainConfigFromChainStore get the current chain configurations from the chain storage

func GetConfigFromSnapshot

func GetConfigFromSnapshot(snapshot protocol.Snapshot) (*config.ChainConfig, error)

GetConfigFromSnapshot get the current chain configurations from snapshot

func GetConsensusNodes

func GetConsensusNodes(conf *config.ChainConfig) []string

GetConsensusNodes returns consensus nodes in the chain configuration

func GetGovernanceContractFromChainStore

func GetGovernanceContractFromChainStore(store protocol.BlockchainStore) (*maxbft.GovernanceContract, error)

GetGovernanceContractFromChainStore get the current governance contract information from the chain storage

func GetGovernanceContractTxRWSet

func GetGovernanceContractTxRWSet(governanceContract *maxbft.GovernanceContract) (*common.TxRWSet, error)

GetGovernanceContractTxRWSet get the transaction rwSet from the given governance contract object

func GetHeightFromQC

func GetHeightFromQC(qc *maxbft.QuorumCert) uint64

GetHeightFromQC returns the block height in the specified quorum certification

func GetMiniNodes

func GetMiniNodes(consensusNodesNum int) uint

GetMiniNodes Calculates the number of nodes for f+1, means that there is at least one honest node in the set.

func GetNodeIdFromSigner

func GetNodeIdFromSigner(signer *accesscontrol.Member,
	ac protocol.AccessControlProvider, net protocol.NetService) (nodeId string, err error)

GetNodeIdFromSigner returns the node to which the specified signer is mapped in Ac module

func GetQCFromBlock

func GetQCFromBlock(block *common.Block) *maxbft.QuorumCert

GetQCFromBlock return the qc in the specified block

func GetQCHeight

func GetQCHeight(proposal *maxbft.ProposalData) uint64

GetQCHeight returns the qc height in the specified proposal

func GetQCView

func GetQCView(proposal *maxbft.ProposalData) uint64

GetQCView returns the view of the specified proposal

func GetQuorum

func GetQuorum(consensusNodesNum int) uint

GetQuorum Counts the number of votes needed to reach a consensus 2f+1

func GetViewFromQC

func GetViewFromQC(qc *maxbft.QuorumCert) uint64

GetViewFromQC returns the view of the specified qc

func InsertQCToBlock

func InsertQCToBlock(block *common.Block, qc *maxbft.QuorumCert)

InsertQCToBlock inserts the specified qc into the specified block

func IsValidator

func IsValidator(node string, validators []string) bool

IsValidator Check whether node is in validators

func MustMarshal

func MustMarshal(msg proto.Message) (data []byte)

MustMarshal marshals protobuf message to byte slice or panic when marshal twice both failed

Types

This section is empty.

Jump to

Keyboard shortcuts

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