Documentation ¶
Overview ¶
Package raft is the raft consensus for ChainMaker
Index ¶
- Variables
- func InitLWS(config *config.ConsensusConfig, waldir string) (lwsInstance *lws.Lws, walWriteMode wal_service.WalWriteMode, err error)
- func VerifyBlockSignatures(block *common.Block) error
- type AdditionalData
- type ConsensusRaftImpl
- func (consensus *ConsensusRaftImpl) AsyncWalSave()
- func (consensus *ConsensusRaftImpl) Close() error
- func (consensus *ConsensusRaftImpl) GetAllNodeInfos() []consensuspb.ConsensusNodeInfo
- func (consensus *ConsensusRaftImpl) GetConsensusStateJSON() ([]byte, error)
- func (consensus *ConsensusRaftImpl) GetConsensusType() consensuspb.ConsensusType
- func (consensus *ConsensusRaftImpl) GetLastHeight() uint64
- func (consensus *ConsensusRaftImpl) GetValidators() ([]string, error)
- func (consensus *ConsensusRaftImpl) IsValidator() bool
- func (consensus *ConsensusRaftImpl) NodeReady(ready etcdraft.Ready)
- func (consensus *ConsensusRaftImpl) OnMessage(message *msgbus.Message)
- func (consensus *ConsensusRaftImpl) OnQuit()
- func (consensus *ConsensusRaftImpl) ProposeBlock(proposalBlock *consensuspb.ProposalBlock)
- func (consensus *ConsensusRaftImpl) Start() error
- func (consensus *ConsensusRaftImpl) Stop() error
- func (consensus *ConsensusRaftImpl) Verify(consensusType consensuspb.ConsensusType, chainConfig *config.ChainConfig) error
- type ConsensusStatus
- type Logger
- type SnapshotArgs
- type SnapshotHeight
- type WalEntry
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultChanCap is the default chan cap in ConsensusRaftImpl DefaultChanCap = 1000 // RAFTAddtionalDataKey is the key for QC RAFTAddtionalDataKey = "RAFTAddtionalDataKey" // AdditionalDataKey for additional data AdditionalDataKey = "AddtionalDataKey" // ErrNotConsensusNode is an error tells that the current node // is a sync node and it not support consensus state interface ErrNotConsensusNode = errors.New("the node is not a consensus node") )
Functions ¶
func InitLWS ¶
func InitLWS(config *config.ConsensusConfig, waldir string) (lwsInstance *lws.Lws, walWriteMode wal_service.WalWriteMode, err error)
InitLWS for wal
func VerifyBlockSignatures ¶
VerifyBlockSignatures verifies whether the signatures in block is qulified with the consensus algorithm. It should return nil error when verify successfully, and return corresponding error when failed. @Description: VerifyBlockSignatures @receiver consensus @param block *common.Block @return error
Types ¶
type AdditionalData ¶
type AdditionalData struct {
Signature []byte
}
AdditionalData contains consensus specified data to be store in block
type ConsensusRaftImpl ¶
type ConsensusRaftImpl struct { sync.RWMutex // the nodeId of etcd-raft Id uint64 // current proposer's nodeId Proposer string // contains filtered or unexported fields }
ConsensusRaftImpl is the implementation of Raft algorithm and it implements the ConsensusEngine interface.
func New ¶
func New(config *consensusUtils.ConsensusImplConfig) (*ConsensusRaftImpl, error)
New creates a raft consensus instance @Description: return ConsensusRaftImpl @receiver consensus @param config @return *ConsensusRaftImpl @return error
func (*ConsensusRaftImpl) AsyncWalSave ¶
func (consensus *ConsensusRaftImpl) AsyncWalSave()
AsyncWalSave write wal asynchronously
func (*ConsensusRaftImpl) Close ¶ added in v3.0.1
func (consensus *ConsensusRaftImpl) Close() error
Close the consensus-engine
func (*ConsensusRaftImpl) GetAllNodeInfos ¶
func (consensus *ConsensusRaftImpl) GetAllNodeInfos() []consensuspb.ConsensusNodeInfo
GetAllNodeInfos returns all consensus nodes' information
func (*ConsensusRaftImpl) GetConsensusStateJSON ¶
func (consensus *ConsensusRaftImpl) GetConsensusStateJSON() ([]byte, error)
GetConsensusStateJSON returns the node status
func (*ConsensusRaftImpl) GetConsensusType ¶
func (consensus *ConsensusRaftImpl) GetConsensusType() consensuspb.ConsensusType
GetConsensusType return consensus type raft @Description: GetConsensusType @receiver consensus @param nil @return ConsensusType consensuspb.ConsensusType
func (*ConsensusRaftImpl) GetLastHeight ¶
func (consensus *ConsensusRaftImpl) GetLastHeight() uint64
GetLastHeight returns last height in ConsensusRaftImpl
func (*ConsensusRaftImpl) GetValidators ¶
func (consensus *ConsensusRaftImpl) GetValidators() ([]string, error)
GetValidators returns all validators for ConsensusRaftImpl
func (*ConsensusRaftImpl) IsValidator ¶ added in v3.0.1
func (consensus *ConsensusRaftImpl) IsValidator() bool
IsValidator checks that the current node is a consensus node or not
func (*ConsensusRaftImpl) NodeReady ¶
func (consensus *ConsensusRaftImpl) NodeReady(ready etcdraft.Ready)
NodeReady process ready msg from etcd-raft
func (*ConsensusRaftImpl) OnMessage ¶
func (consensus *ConsensusRaftImpl) OnMessage(message *msgbus.Message)
OnMessage receives messages from msgbus @Description: msgbus @receiver consensus @param message @return nil
func (*ConsensusRaftImpl) OnQuit ¶
func (consensus *ConsensusRaftImpl) OnQuit()
OnQuit is on quit for msgbus @Description: OnQuit @receiver consensus @param nil @return nil
func (*ConsensusRaftImpl) ProposeBlock ¶
func (consensus *ConsensusRaftImpl) ProposeBlock(proposalBlock *consensuspb.ProposalBlock)
ProposeBlock process proposed block from core engine
func (*ConsensusRaftImpl) Start ¶
func (consensus *ConsensusRaftImpl) Start() error
Start starts the raft instance @Description: start engine @receiver consensus @param nil @return error
func (*ConsensusRaftImpl) Stop ¶
func (consensus *ConsensusRaftImpl) Stop() error
Stop stops the raft instance, we have to do nothing in here because we can't stopped by the blockChain directly, we should tell etcd-raft that the current node was removed by some configuration changing before exit
func (*ConsensusRaftImpl) Verify ¶
func (consensus *ConsensusRaftImpl) Verify( consensusType consensuspb.ConsensusType, chainConfig *config.ChainConfig) error
Verify implements interface of struct Verifier, This interface is used to verify the validity of parameters, it executes before consensus. @Description: Verify @receiver consensus @param nil @return nil
type ConsensusStatus ¶
type ConsensusStatus struct { Height uint64 CommittedHeight uint64 Proposer string Validators []string }
ConsensusStatus describe the current status of the consensus cluster
type Logger ¶
type Logger struct { *zap.SugaredLogger // contains filtered or unexported fields }
Logger implements raft.Logger interface with wraping zap.SugaredLogger
func NewLogger ¶
func NewLogger(lg *zap.SugaredLogger) *Logger
NewLogger creates a new Logger instance
type SnapshotArgs ¶
SnapshotArgs is snapshot args for raft