Documentation
¶
Index ¶
- Variables
- func CheckConsensusVersion(hisMap map[int]def.ConsensusConfig, cfg *def.ConsensusConfig) error
- func NewPluginConsensus(cCtx cctx.ConsensusCtx, cCfg def.ConsensusConfig) (base.ConsensusImplInterface, error)
- func Register(name string, f NewStepConsensus) error
- type ConsensusInterface
- type NewStepConsensus
- type PluggableConsensus
- func (pc *PluggableConsensus) CalculateBlock(block cctx.BlockInterface) error
- func (pc *PluggableConsensus) CheckMinerMatch(ctx xcontext.XContext, block cctx.BlockInterface) (bool, error)
- func (pc *PluggableConsensus) CompeteMaster(height int64) (bool, bool, error)
- func (pc *PluggableConsensus) GetConsensusStatus() (base.ConsensusStatus, error)
- func (pc *PluggableConsensus) ProcessBeforeMiner(timestamp int64) ([]byte, []byte, error)
- func (pc *PluggableConsensus) ProcessConfirmBlock(block cctx.BlockInterface) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( EmptyConsensusListErr = errors.New("Consensus list of PluggableConsensus is empty.") EmptyConsensusName = errors.New("Consensus name can not be empty") EmptyConfig = errors.New("Config name can not be empty") UpdateTriggerError = errors.New("Update trigger height invalid") BeginBlockIdErr = errors.New("Consensus begin blockid err") BuildConsensusError = errors.New("Build consensus Error") ConsensusNotRegister = errors.New("Consensus 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, or try an empty config JSON when you need rollback") )
Functions ¶
func CheckConsensusVersion ¶
func CheckConsensusVersion(hisMap map[int]def.ConsensusConfig, cfg *def.ConsensusConfig) error
CheckConsensusConfig 同名配置文件检查: 1. 若历史相同version,则直接返回历史cfg 2. 若不存在,需要比历史最大值大 3. 将合法的配置写到map中
func NewPluginConsensus ¶
func NewPluginConsensus(cCtx cctx.ConsensusCtx, cCfg def.ConsensusConfig) (base.ConsensusImplInterface, error)
NewPluginConsensus 新建可插拔共识实例
Types ¶
type ConsensusInterface ¶
type ConsensusInterface interface {
// CompeteMaster 返回是否为矿工以及是否需要进行SyncBlock
CompeteMaster(height int64) (bool, bool, error)
// CheckMinerMatch 当前block是否合法
CheckMinerMatch(ctx xcontext.XContext, block cctx.BlockInterface) (bool, error)
// ProcessBeforeMiner 开始挖矿前进行相应的处理, 返回truncate目标(如需裁剪), 返回写consensusStorage, 返回err
ProcessBeforeMiner(timestamp int64) ([]byte, []byte, error)
// CalculateBlock 矿工挖矿时共识需要做的工作, 如PoW时共识需要完成存在性证明
CalculateBlock(block cctx.BlockInterface) error
// ProcessConfirmBlock 用于确认块后进行相应的处理
ProcessConfirmBlock(block cctx.BlockInterface) error
// GetStatus 获取区块链共识信息
GetConsensusStatus() (base.ConsensusStatus, error)
}
ConsensusInterface 定义了一个共识实例需要实现的接口,用于kernel外的调用
func NewPluggableConsensus ¶
func NewPluggableConsensus(cCtx cctx.ConsensusCtx) (ConsensusInterface, error)
NewPluggableConsensus 初次创建PluggableConsensus实例,初始化cons列表
type NewStepConsensus ¶
type NewStepConsensus func(cCtx cctx.ConsensusCtx, cCfg def.ConsensusConfig) base.ConsensusImplInterface
type PluggableConsensus ¶
type PluggableConsensus struct {
// contains filtered or unexported fields
}
PluggableConsensus 实现了consensus_interface接口
func (*PluggableConsensus) CalculateBlock ¶
func (pc *PluggableConsensus) CalculateBlock(block cctx.BlockInterface) error
CalculateBlock 矿工挖矿时共识需要做的工作, 如PoW时共识需要完成存在性证明
func (*PluggableConsensus) CheckMinerMatch ¶
func (pc *PluggableConsensus) CheckMinerMatch(ctx xcontext.XContext, block cctx.BlockInterface) (bool, error)
CheckMinerMatch 调用具体实例的CheckMinerMatch()
func (*PluggableConsensus) CompeteMaster ¶
func (pc *PluggableConsensus) CompeteMaster(height int64) (bool, bool, error)
CompeteMaster 矿工检查当前自己是否需要挖矿 param: height仅为打印需要的标示,实际还是需要账本当前最高 的高度作为输入
func (*PluggableConsensus) GetConsensusStatus ¶
func (pc *PluggableConsensus) GetConsensusStatus() (base.ConsensusStatus, error)
GetConsensusStatus 调用具体实例的GetConsensusStatus(),返回接口
func (*PluggableConsensus) ProcessBeforeMiner ¶
func (pc *PluggableConsensus) ProcessBeforeMiner(timestamp int64) ([]byte, []byte, error)
ProcessBeforeMinerm调用具体实例的ProcessBeforeMiner()
func (*PluggableConsensus) ProcessConfirmBlock ¶
func (pc *PluggableConsensus) ProcessConfirmBlock(block cctx.BlockInterface) error
ProcessConfirmBlock 调用具体实例的ProcessConfirmBlock()
Directories
¶
| Path | Synopsis |
|---|---|
|
driver/chained-bft/main
command
|
|
|
明确定义该模块需要的上下文信息,方便代码阅读和理解
|
明确定义该模块需要的上下文信息,方便代码阅读和理解 |
Click to show internal directories.
Click to hide internal directories.