consensus

package
v0.0.0-...-b124b1e Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyConsensusListErr = errors.New("CommonConsensus list of PluggableConsensusImpl is empty.")
	EmptyConsensusName    = errors.New("CommonConsensus name can not be empty")
	EmptyConfig           = errors.New("Config name can not be empty")
	UpdateTriggerError    = errors.New("Update trigger height invalid")
	BeginBlockIdErr       = errors.New("CommonConsensus begin blockid err")
	BuildConsensusError   = errors.New("Build consensus Error")
	ConsensusNotRegister  = errors.New("CommonConsensus hasn't been register. Please use consensus.Register({NAME},{FUNCTION_POINTER}) to register in consensusMap")
	ContractMngErr        = errors.New("Contract manager is empty.")

	ErrInvalidConfig  = errors.New("config should be an empty JSON when rolling back an old one, or try an upper version")
	ErrInvalidVersion = errors.New("version should be an upper one when upgrading a new one")
)

Functions

func NewPluggableConsensus

func NewPluggableConsensus(cctx base.ConsensusCtx) (base.PluggableConsensus, error)

NewPluggableConsensus 初次创建PluggableConsensus实例,初始化可插拔共识列表

func NewPluginConsensus

func NewPluginConsensus(cctx base.ConsensusCtx, ccfg base.ConsensusConfig) (base.CommonConsensus, error)

NewPluginConsensus 新建可插拔共识实例

func Register

func Register(name string, f NewStepConsensus) error

Register 注册共识协议

Types

type NewStepConsensus

type NewStepConsensus func(cctx base.ConsensusCtx, ccfg base.ConsensusConfig) base.CommonConsensus

type PluggableConsensusImpl

type PluggableConsensusImpl struct {
	// contains filtered or unexported fields
}

PluggableConsensusImpl 利用stepConsensus实现可插拔共识

func (*PluggableConsensusImpl) CalculateBlock

func (pc *PluggableConsensusImpl) CalculateBlock(block ledger.BlockHandle) error

CalculateBlock 矿工挖矿时共识需要做的工作, 如PoW时共识需要完成存在性证明

func (*PluggableConsensusImpl) CheckMinerMatch

func (pc *PluggableConsensusImpl) CheckMinerMatch(ctx xctx.Context, block ledger.BlockHandle) (bool, error)

CheckMinerMatch 调用具体实例的CheckMinerMatch()

func (*PluggableConsensusImpl) CompeteMaster

func (pc *PluggableConsensusImpl) CompeteMaster(height int64) (bool, bool, error)

CompeteMaster 矿工检查当前自己是否需要挖矿,需要账本当前最高的高度作为输入

func (*PluggableConsensusImpl) GetConsensusStatus

func (pc *PluggableConsensusImpl) GetConsensusStatus() (base.ConsensusStatus, error)

GetConsensusStatus 调用具体实例的GetConsensusStatus()

func (*PluggableConsensusImpl) ProcessBeforeMiner

func (pc *PluggableConsensusImpl) ProcessBeforeMiner(height, timestamp int64) ([]byte, []byte, error)

ProcessBeforeMiner 调用具体实例的ProcessBeforeMiner()

func (*PluggableConsensusImpl) ProcessConfirmBlock

func (pc *PluggableConsensusImpl) ProcessConfirmBlock(block ledger.BlockHandle) error

ProcessConfirmBlock 调用具体实例的ProcessConfirmBlock()

func (*PluggableConsensusImpl) SwitchConsensus

func (pc *PluggableConsensusImpl) SwitchConsensus(height int64) error

SwitchConsensus 用于共识升级时切换共识实例

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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