Documentation ¶
Index ¶
- Variables
- func GetContractFromDB(store protocol.BlockchainStore) (*maxbft.GovernanceContract, error)
- func GetEpochStrategyFromConfig(cfg *config.ChainConfig) (strategy string, number uint64, err error)
- func GetViewsPerEpochForV230(config *config.ChainConfig) uint64
- type BaseOnConfig
- func (t *BaseOnConfig) CheckConfig(config *config.ChainConfig) error
- func (t *BaseOnConfig) CheckEpochRWSet(prev *common.Block, proposal *maxbft.ProposalData) error
- func (t *BaseOnConfig) CreateEpochTxRWSet(prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
- func (t *BaseOnConfig) End(finalBlock *forest.BlockContainer) bool
- func (t *BaseOnConfig) SetEpochStatus(contract *maxbft.GovernanceContract)
- func (t *BaseOnConfig) Strategy() string
- type BasedOnHeight
- func (b *BasedOnHeight) CheckConfig(config *config.ChainConfig) error
- func (b *BasedOnHeight) CheckEpochRWSet(prev *common.Block, proposal *maxbft.ProposalData) error
- func (b *BasedOnHeight) CreateEpochTxRWSet(prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
- func (b *BasedOnHeight) End(finalBlock *forest.BlockContainer) bool
- func (b *BasedOnHeight) SetEpochStatus(contract *maxbft.GovernanceContract)
- func (b *BasedOnHeight) Strategy() string
- type BasedOnView
- func (b *BasedOnView) CheckConfig(config *config.ChainConfig) error
- func (b *BasedOnView) CheckEpochRWSet(prev *common.Block, proposal *maxbft.ProposalData) error
- func (b *BasedOnView) CreateEpochTxRWSet(prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
- func (b *BasedOnView) End(finalBlock *forest.BlockContainer) bool
- func (b *BasedOnView) SetEpochStatus(contract *maxbft.GovernanceContract)
- func (b *BasedOnView) Strategy() string
- type Epoch
- type EpochManager
- func (manager *EpochManager) ConstructEpoch(prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
- func (manager *EpochManager) GetEpochStrategy() string
- func (manager *EpochManager) IsEndInEpoch(finalBlock *forest.BlockContainer) bool
- func (manager *EpochManager) SwitchEpoch(contract *maxbft.GovernanceContract) error
- func (manager *EpochManager) VerifyConfig(chainConfig *config.ChainConfig) error
- func (manager *EpochManager) VerifyEpochContract(prevBlock *common.Block, proposal *maxbft.ProposalData) error
- type Manager
- type StateEngine
Constants ¶
This section is empty.
Variables ¶
var ( // ViewStrategy View-based epoch switching strategy ViewStrategy = strings.ToLower("BasedOnView") // HeightStrategy Height-based epoch switching strategy HeightStrategy = strings.ToLower("BasedOnHeight") // ConfigChangeStrategy chainConfigChange-based epoch switching strategy ConfigChangeStrategy = strings.ToLower("BasedOnConfig") )
Functions ¶
func GetContractFromDB ¶
func GetContractFromDB(store protocol.BlockchainStore) (*maxbft.GovernanceContract, error)
GetContractFromDB get epochContract from DB
func GetEpochStrategyFromConfig ¶
func GetEpochStrategyFromConfig(cfg *config.ChainConfig) (strategy string, number uint64, err error)
GetEpochStrategyFromConfig get strategy of epoch from chainConfig
func GetViewsPerEpochForV230 ¶
func GetViewsPerEpochForV230(config *config.ChainConfig) uint64
GetViewsPerEpochForV230 get views num in each epoch on v230 chainVersion
Types ¶
type BaseOnConfig ¶
type BaseOnConfig struct {
// contains filtered or unexported fields
}
BaseOnConfig configChange-based epoch switching strategy
func NewBaseOnConfig ¶
func NewBaseOnConfig(log protocol.Logger, snapshotManager protocol.SnapshotManager, epochId uint64) (*BaseOnConfig, error)
NewBaseOnConfig init
func (*BaseOnConfig) CheckConfig ¶
func (t *BaseOnConfig) CheckConfig(config *config.ChainConfig) error
CheckConfig verify the chainConfig when update
func (*BaseOnConfig) CheckEpochRWSet ¶
func (t *BaseOnConfig) CheckEpochRWSet(prev *common.Block, proposal *maxbft.ProposalData) error
CheckEpochRWSet verify the read and write set of the epoch within proposal
func (*BaseOnConfig) CreateEpochTxRWSet ¶
func (t *BaseOnConfig) CreateEpochTxRWSet( prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
CreateEpochTxRWSet Create a new epoch read and write set
func (*BaseOnConfig) End ¶
func (t *BaseOnConfig) End(finalBlock *forest.BlockContainer) bool
End Determine whether the current epoch has ended
func (*BaseOnConfig) SetEpochStatus ¶
func (t *BaseOnConfig) SetEpochStatus(contract *maxbft.GovernanceContract)
SetEpochStatus set status of the new epoch
type BasedOnHeight ¶
type BasedOnHeight struct {
// contains filtered or unexported fields
}
BasedOnHeight Height-based epoch switching strategy
func NewBasedOnHeight ¶
func NewBasedOnHeight(epochId, endHeight, numberInPerEpoch uint64, manager protocol.SnapshotManager, log protocol.Logger) (*BasedOnHeight, error)
NewBasedOnHeight new epoch
func (*BasedOnHeight) CheckConfig ¶
func (b *BasedOnHeight) CheckConfig(config *config.ChainConfig) error
CheckConfig verify the chainConfig when update
func (*BasedOnHeight) CheckEpochRWSet ¶
func (b *BasedOnHeight) CheckEpochRWSet(prev *common.Block, proposal *maxbft.ProposalData) error
CheckEpochRWSet verify the read and write set of the epoch within proposal
func (*BasedOnHeight) CreateEpochTxRWSet ¶
func (b *BasedOnHeight) CreateEpochTxRWSet( prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
CreateEpochTxRWSet Create a new epoch read and write set
func (*BasedOnHeight) End ¶
func (b *BasedOnHeight) End(finalBlock *forest.BlockContainer) bool
End Whether to go to the next state true go to the next state in current epoch; otherwise return false
func (*BasedOnHeight) SetEpochStatus ¶
func (b *BasedOnHeight) SetEpochStatus(contract *maxbft.GovernanceContract)
SetEpochStatus set status of the new epoch
type BasedOnView ¶
type BasedOnView struct {
// contains filtered or unexported fields
}
BasedOnView View-based epoch switching strategy
func NewBasedOnView ¶
func NewBasedOnView(epochId, endView, viewNumsPerEpoch uint64, manager protocol.SnapshotManager, log protocol.Logger) (*BasedOnView, error)
NewBasedOnView new epoch
func (*BasedOnView) CheckConfig ¶
func (b *BasedOnView) CheckConfig(config *config.ChainConfig) error
CheckConfig verify the chainConfig when update
func (*BasedOnView) CheckEpochRWSet ¶
func (b *BasedOnView) CheckEpochRWSet(prev *common.Block, proposal *maxbft.ProposalData) error
CheckEpochRWSet verify the read and write set of the epoch within proposal
func (*BasedOnView) CreateEpochTxRWSet ¶
func (b *BasedOnView) CreateEpochTxRWSet( prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
CreateEpochTxRWSet Create a new epoch read and write set
func (*BasedOnView) End ¶
func (b *BasedOnView) End(finalBlock *forest.BlockContainer) bool
End Whether to go to the next state true go to the next state in current epoch; otherwise return false
func (*BasedOnView) SetEpochStatus ¶
func (b *BasedOnView) SetEpochStatus(contract *maxbft.GovernanceContract)
SetEpochStatus set status of the new epoch
type Epoch ¶
type Epoch interface { // CreateEpochTxRWSet Create a new epoch read and write set CreateEpochTxRWSet(prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error) // CheckConfig verify the chainConfig when update CheckConfig(config *config.ChainConfig) error // CheckEpochRWSet verify the read and write set of the epoch within proposal CheckEpochRWSet(prev *common.Block, proposal *maxbft.ProposalData) error // SetEpochStatus set status of the new epoch SetEpochStatus(contract *maxbft.GovernanceContract) // End Determine whether the current epoch has ended End(finalBlock *forest.BlockContainer) bool // Strategy of the epoch Strategy() string }
Epoch feature Interface
type EpochManager ¶
type EpochManager struct {
// contains filtered or unexported fields
}
EpochManager which creates and proxies tasks for epoch
func NewEpochManager ¶
func NewEpochManager(cfg protocol.ChainConf, snapshotManager protocol.SnapshotManager, log protocol.Logger, engine StateEngine, contractState *maxbft.GovernanceContract) (*EpochManager, error)
NewEpochManager create EpochManager by the chainConfig
func (*EpochManager) ConstructEpoch ¶
func (manager *EpochManager) ConstructEpoch( prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error)
ConstructEpoch construct the state content for the new epoch
func (*EpochManager) GetEpochStrategy ¶
func (manager *EpochManager) GetEpochStrategy() string
GetEpochStrategy get epoch strategy
func (*EpochManager) IsEndInEpoch ¶
func (manager *EpochManager) IsEndInEpoch(finalBlock *forest.BlockContainer) bool
IsEndInEpoch Check that the current epoch is over and the last submitted block is the end block. true: End of the epoch, otherwise is false
func (*EpochManager) SwitchEpoch ¶
func (manager *EpochManager) SwitchEpoch(contract *maxbft.GovernanceContract) error
SwitchEpoch Make the epoch switch
func (*EpochManager) VerifyConfig ¶
func (manager *EpochManager) VerifyConfig(chainConfig *config.ChainConfig) error
VerifyConfig Verify chain configuration update with epoch
func (*EpochManager) VerifyEpochContract ¶
func (manager *EpochManager) VerifyEpochContract(prevBlock *common.Block, proposal *maxbft.ProposalData) error
VerifyEpochContract Verify the new epoch content within received block
type Manager ¶
type Manager interface { // ConstructEpoch construct the state content for the new epoch ConstructEpoch(prevBlock *common.Block, proposal *maxbft.ProposalData) (*common.TxRWSet, error) // SwitchEpoch Make the epoch switch SwitchEpoch(*maxbft.GovernanceContract) error // VerifyConfig Verify chain configuration update with epoch VerifyConfig(chainConfig *config.ChainConfig) error // VerifyEpochContract Verify the new epoch content within received block VerifyEpochContract(prev *common.Block, proposal *maxbft.ProposalData) error // IsEndInEpoch Check that the current epoch is over and the last submitted block is the end block. // true: End of the epoch, otherwise is false IsEndInEpoch(finalBlock *forest.BlockContainer) bool // GetEpochStrategy get epoch strategy GetEpochStrategy() string }
Manager epoch manager
type StateEngine ¶
type StateEngine interface { // SwitchState update the state within the engine to a new generation SwitchState(contract *maxbft.GovernanceContract) error }
StateEngine An engine that requires status updates when switching epoch