Documentation ¶
Index ¶
- Constants
- Variables
- func GetF2() int
- func Hash(content []byte) string
- type ConfirmMsg
- func (m *ConfirmMsg) GetCompleted() []*types.HBFTStageCompleted
- func (m *ConfirmMsg) GetCurStage() Stage
- func (m *ConfirmMsg) GetMsgHash() common.Hash
- func (m *ConfirmMsg) GetMsgType() TypeHBFTMsg
- func (m *ConfirmMsg) GetNewBlock() *types.Block
- func (m *ConfirmMsg) GetSequenceID() uint64
- func (m *ConfirmMsg) GetSignature() []byte
- func (m *ConfirmMsg) GetViewID() uint64
- func (m *ConfirmMsg) GetViewPrimary() string
- func (msg *ConfirmMsg) Hash() common.Hash
- type MsgHbftConsensus
- type MsgLogs
- type PreConfirmMsg
- func (m *PreConfirmMsg) GetCompleted() []*types.HBFTStageCompleted
- func (m *PreConfirmMsg) GetCurStage() Stage
- func (m *PreConfirmMsg) GetMsgHash() common.Hash
- func (m *PreConfirmMsg) GetMsgType() TypeHBFTMsg
- func (m *PreConfirmMsg) GetNewBlock() *types.Block
- func (m *PreConfirmMsg) GetSequenceID() uint64
- func (m *PreConfirmMsg) GetSignature() []byte
- func (m *PreConfirmMsg) GetViewID() uint64
- func (m *PreConfirmMsg) GetViewPrimary() string
- func (msg *PreConfirmMsg) Hash() common.Hash
- type ReplyMsg
- func (m *ReplyMsg) GetCompleted() []*types.HBFTStageCompleted
- func (m *ReplyMsg) GetCurStage() Stage
- func (m *ReplyMsg) GetMsgHash() common.Hash
- func (m *ReplyMsg) GetMsgType() TypeHBFTMsg
- func (m *ReplyMsg) GetNewBlock() *types.Block
- func (m *ReplyMsg) GetSequenceID() uint64
- func (m *ReplyMsg) GetSignature() []byte
- func (m *ReplyMsg) GetViewID() uint64
- func (m *ReplyMsg) GetViewPrimary() string
- func (msg *ReplyMsg) Hash() common.Hash
- type RequestMsg
- func (m *RequestMsg) GetCompleted() []*types.HBFTStageCompleted
- func (m *RequestMsg) GetCurStage() Stage
- func (m *RequestMsg) GetMsgHash() common.Hash
- func (m *RequestMsg) GetMsgType() TypeHBFTMsg
- func (m *RequestMsg) GetNewBlock() *types.Block
- func (m *RequestMsg) GetSequenceID() uint64
- func (m *RequestMsg) GetSignature() []byte
- func (m *RequestMsg) GetViewID() uint64
- func (m *RequestMsg) GetViewPrimary() string
- func (m *RequestMsg) Hash() common.Hash
- type Stage
- type State
- func (state *State) AppendBlock(b *types.Block)
- func (state *State) BuildCompletedStageChain() (stages []*types.HBFTStageCompleted)
- func (state *State) CheckCompletedStage(completedStages []*types.HBFTStageCompleted, currentBlock *types.Block, ...) error
- func (state *State) CheckCurrentState(msg interface{}, currentBlock, BFTFuture *types.Block, cnt2f int) error
- func (state *State) CheckView(msg interface{}) error
- func (state *State) ClearConnected(newHead *types.Header)
- func (state *State) GetNewestCompletedStage(currentBlock *types.Block) *types.HBFTStageCompleted
- func (state *State) GetNewestStateCompletedStage() *types.HBFTStageCompleted
- func (state *State) Reset(clearCompleted bool)
- func (state State) SetStageCompleted(stage *types.HBFTStageCompleted)
- func (state *State) StartConsensus(request *RequestMsg, replys *[]*ReplyMsg, currentBlock *types.Block) (*PreConfirmMsg, error)
- type StateMsg
- type TypeHBFTMsg
Constants ¶
View Source
const ( SameViewPrimaryErr = "BFT message from the same view" InvalidViewOrSeqIDErr = "the view ID or sequence ID of BFT message is not valid" InvalidParentHashErr = "the hash of the parent completed stage is not valid" InvalidSignsCntErr = "the signatures of the completed stage is not sufficient" NoSpecificBlockErr = "the block in the stage is not received" InvalidNewBlockErr = "new block that the BFT message contained is not valid" InvalidCompletedErr = "the completed stage is not valid" ShouldNotHandleErr = "the message we received should not be handled due to the stage of the node" )
Variables ¶
View Source
var ( EmptyPreConfirmMsg = &PreConfirmMsg{ NewBlock: types.NewBlockWithHeader(types.EmptyHeader), CurState: &StateMsg{ Completed: make([]*types.HBFTStageCompleted, 0), }, } EmptyConfirmMsg = &ConfirmMsg{ CurState: &StateMsg{ Completed: make([]*types.HBFTStageCompleted, 0), }, } EmptyReplyMsg = &ReplyMsg{ MsgHash: common.Hash{}, } )
Functions ¶
Types ¶
type ConfirmMsg ¶
type ConfirmMsg struct { ViewPrimary string `json:"viewPrimary"` ViewID uint64 `json:"viewID"` SequenceID uint64 `json:"sequenceID"` CurState *StateMsg `json:"curState"` Signature []byte `json:"signature"` }
func (*ConfirmMsg) GetCompleted ¶
func (m *ConfirmMsg) GetCompleted() []*types.HBFTStageCompleted
func (*ConfirmMsg) GetCurStage ¶
func (m *ConfirmMsg) GetCurStage() Stage
func (*ConfirmMsg) GetMsgHash ¶
func (m *ConfirmMsg) GetMsgHash() common.Hash
func (*ConfirmMsg) GetMsgType ¶
func (m *ConfirmMsg) GetMsgType() TypeHBFTMsg
func (*ConfirmMsg) GetNewBlock ¶
func (m *ConfirmMsg) GetNewBlock() *types.Block
func (*ConfirmMsg) GetSequenceID ¶
func (m *ConfirmMsg) GetSequenceID() uint64
func (*ConfirmMsg) GetSignature ¶
func (m *ConfirmMsg) GetSignature() []byte
func (*ConfirmMsg) GetViewID ¶
func (m *ConfirmMsg) GetViewID() uint64
func (*ConfirmMsg) GetViewPrimary ¶
func (m *ConfirmMsg) GetViewPrimary() string
func (*ConfirmMsg) Hash ¶
func (msg *ConfirmMsg) Hash() common.Hash
type MsgHbftConsensus ¶
type MsgLogs ¶
type MsgLogs struct { ReqMsg *RequestMsg PreConfirmMsgs map[string]*PreConfirmMsg ConfirmMsgs map[string]*ConfirmMsg }
type PreConfirmMsg ¶
type PreConfirmMsg struct { ViewPrimary string `json:"viewPrimary"` ViewID uint64 `json:"viewID"` SequenceID uint64 `json:"sequenceID"` NewBlock *types.Block `json:"newBlock"` CurState *StateMsg `json:"curState"` Signature []byte `json:"signature"` }
func (*PreConfirmMsg) GetCompleted ¶
func (m *PreConfirmMsg) GetCompleted() []*types.HBFTStageCompleted
func (*PreConfirmMsg) GetCurStage ¶
func (m *PreConfirmMsg) GetCurStage() Stage
func (*PreConfirmMsg) GetMsgHash ¶
func (m *PreConfirmMsg) GetMsgHash() common.Hash
func (*PreConfirmMsg) GetMsgType ¶
func (m *PreConfirmMsg) GetMsgType() TypeHBFTMsg
func (*PreConfirmMsg) GetNewBlock ¶
func (m *PreConfirmMsg) GetNewBlock() *types.Block
func (*PreConfirmMsg) GetSequenceID ¶
func (m *PreConfirmMsg) GetSequenceID() uint64
func (*PreConfirmMsg) GetSignature ¶
func (m *PreConfirmMsg) GetSignature() []byte
func (*PreConfirmMsg) GetViewID ¶
func (m *PreConfirmMsg) GetViewID() uint64
func (*PreConfirmMsg) GetViewPrimary ¶
func (m *PreConfirmMsg) GetViewPrimary() string
func (*PreConfirmMsg) Hash ¶
func (msg *PreConfirmMsg) Hash() common.Hash
type ReplyMsg ¶
type ReplyMsg struct { ViewPrimary string `json:"viewPrimary"` ViewID uint64 `json:"viewID"` SequenceID uint64 `json:"sequenceID"` MsgType TypeHBFTMsg `json:"MsgType"` MsgHash common.Hash `json:"msgHash"` Signature []byte `json:"signature"` }
func (*ReplyMsg) GetCompleted ¶
func (m *ReplyMsg) GetCompleted() []*types.HBFTStageCompleted
func (*ReplyMsg) GetCurStage ¶
func (*ReplyMsg) GetMsgHash ¶
func (*ReplyMsg) GetMsgType ¶
func (m *ReplyMsg) GetMsgType() TypeHBFTMsg
func (*ReplyMsg) GetNewBlock ¶
func (*ReplyMsg) GetSequenceID ¶
func (*ReplyMsg) GetSignature ¶
func (*ReplyMsg) GetViewPrimary ¶
type RequestMsg ¶
type RequestMsg struct { ViewPrimary string `json:"viewPrimary"` ViewID uint64 `json:"viewID"` Timestamp uint64 `json:"timestamp"` SequenceID uint64 `json:"sequenceID"` NewBlock *types.Block `json:"newBlock"` }
func (*RequestMsg) GetCompleted ¶
func (m *RequestMsg) GetCompleted() []*types.HBFTStageCompleted
func (*RequestMsg) GetCurStage ¶
func (m *RequestMsg) GetCurStage() Stage
func (*RequestMsg) GetMsgHash ¶
func (m *RequestMsg) GetMsgHash() common.Hash
func (*RequestMsg) GetMsgType ¶
func (m *RequestMsg) GetMsgType() TypeHBFTMsg
func (*RequestMsg) GetNewBlock ¶
func (m *RequestMsg) GetNewBlock() *types.Block
func (*RequestMsg) GetSequenceID ¶
func (m *RequestMsg) GetSequenceID() uint64
func (*RequestMsg) GetSignature ¶
func (m *RequestMsg) GetSignature() []byte
func (*RequestMsg) GetViewID ¶
func (m *RequestMsg) GetViewID() uint64
func (*RequestMsg) GetViewPrimary ¶
func (m *RequestMsg) GetViewPrimary() string
func (*RequestMsg) Hash ¶
func (m *RequestMsg) Hash() common.Hash
type Stage ¶
type Stage uint
stage represents that the node in which state in the consensus process
const ( Idle Stage = iota // Node is created successfully, but the consensus process is not started yet. PreConfirm // The `preConfirmMsg` is processed successfully. The node is ready to head to the Confirm stage. Confirm // The `confirmMsg` is processed successfully. The node is ready to head to the next block processing. InvalidStage // Unavailable stage )
type State ¶
type State struct { ViewPrimary string ViewID uint64 SequenceID uint64 CurrentStage Stage MsgHash common.Hash Blocks []*types.Block Completed map[common.Hash]*types.HBFTStageCompleted MsgLogs *MsgLogs // contains filtered or unexported fields }
func CreateState ¶
func CreateState(viewPrimary string, viewID uint64, sequenceID uint64, blocks []*types.Block) *State
lastSequenceID will be -1 if there is no last sequence ID.
func (*State) AppendBlock ¶
func (*State) BuildCompletedStageChain ¶
func (state *State) BuildCompletedStageChain() (stages []*types.HBFTStageCompleted)
func (*State) CheckCompletedStage ¶
func (*State) CheckCurrentState ¶
func (*State) ClearConnected ¶
func (*State) GetNewestCompletedStage ¶
func (state *State) GetNewestCompletedStage(currentBlock *types.Block) *types.HBFTStageCompleted
func (*State) GetNewestStateCompletedStage ¶
func (state *State) GetNewestStateCompletedStage() *types.HBFTStageCompleted
func (State) SetStageCompleted ¶
func (state State) SetStageCompleted(stage *types.HBFTStageCompleted)
func (*State) StartConsensus ¶
func (state *State) StartConsensus(request *RequestMsg, replys *[]*ReplyMsg, currentBlock *types.Block) (*PreConfirmMsg, error)
type StateMsg ¶
type StateMsg struct { ViewID uint64 SequenceID uint64 CurrentStage Stage Completed []*types.HBFTStageCompleted }
type TypeHBFTMsg ¶
type TypeHBFTMsg uint
const ( MsgPreConfirm TypeHBFTMsg = iota MsgConfirm MsgReply MsgInvalid )
Click to show internal directories.
Click to hide internal directories.