Documentation ¶
Index ¶
- Variables
- func NewPluggableConsensus(cctx base.ConsensusCtx) (base.PluggableConsensus, error)
- func NewPluginConsensus(cctx base.ConsensusCtx, ccfg base.ConsensusConfig) (base.CommonConsensus, error)
- func Register(name string, f NewStepConsensus) error
- type NewStepConsensus
- type PluggableConsensusImpl
- func (pc *PluggableConsensusImpl) CalculateBlock(block ledger.BlockHandle) error
- func (pc *PluggableConsensusImpl) CheckMinerMatch(ctx xctx.Context, block ledger.BlockHandle) (bool, error)
- func (pc *PluggableConsensusImpl) CompeteMaster(height int64) (bool, bool, error)
- func (pc *PluggableConsensusImpl) GetConsensusStatus() (base.ConsensusStatus, error)
- func (pc *PluggableConsensusImpl) ProcessBeforeMiner(height, timestamp int64) ([]byte, []byte, error)
- func (pc *PluggableConsensusImpl) ProcessConfirmBlock(block ledger.BlockHandle) error
- func (pc *PluggableConsensusImpl) SwitchConsensus(height int64) error
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 新建可插拔共识实例
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 用于共识升级时切换共识实例
Click to show internal directories.
Click to hide internal directories.