Documentation
¶
Index ¶
- Constants
- Variables
- func CopyBlock(block *common.Block) *common.Block
- func CopyProposalWithBlockHeader(p *tbftpb.Proposal) *tbftpb.Proposal
- func CurrentTime() time.Time
- func GetValidatorList(chainConfig *config.ChainConfig, store protocol.BlockchainStore) (validators []string, err error)
- func GetValidatorListFromConfig(chainConfig *config.ChainConfig) (validators []string, err error)
- func InitLWS(config *config.ConsensusConfig, chainId, nodeId string) (lwsInstance *lws.Lws, walWriteMode wal_service.WalWriteMode, err error)
- func MarshalTBFTProposalFE(tbftProposal *TBFTProposal)
- func NewProposal(voter string, height uint64, round int32, polRound int32, block *common.Block) *tbftpb.Proposal
- func NewProposalBlock(block *common.Block, txsRwSet map[string]*common.TxRWSet) *consensuspb.ProposalBlock
- func NewVote(typ tbftpb.VoteType, voter string, height uint64, round int32, hash []byte) *tbftpb.Vote
- func VerifyBlockSignatures(chainConf protocol.ChainConf, ac protocol.AccessControlProvider, ...) error
- func VerifyRoundQc(logger protocol.Logger, ac protocol.AccessControlProvider, ...) error
- type BlockFEVotes
- type BlockVotes
- type ConsensusFutureMsg
- type ConsensusFutureMsgCache
- type ConsensusMsg
- type ConsensusState
- type ConsensusTBFTImpl
- func (consensus *ConsensusTBFTImpl) AddTimeout(duration time.Duration, height uint64, round int32, step tbftpb.Step)
- func (consensus *ConsensusTBFTImpl) CommitTimeout(round int32) time.Duration
- func (consensus *ConsensusTBFTImpl) Data() interface{}
- func (consensus *ConsensusTBFTImpl) GetConsensusStateJSON() ([]byte, error)
- func (consensus *ConsensusTBFTImpl) GetLastHeight() uint64
- func (consensus *ConsensusTBFTImpl) GetValidators() ([]string, error)
- func (consensus *ConsensusTBFTImpl) InitConsistentEngine()
- func (consensus *ConsensusTBFTImpl) InitExtendHandler(handler protocol.ConsensusExtendHandler)
- func (consensus *ConsensusTBFTImpl) NewGaugeVec(nodeId string, gaugeType int)
- func (consensus *ConsensusTBFTImpl) OnMessage(message *msgbus.Message)
- func (consensus *ConsensusTBFTImpl) OnQuit()
- func (consensus *ConsensusTBFTImpl) PrecommitTimeout(round int32) time.Duration
- func (consensus *ConsensusTBFTImpl) PrevoteTimeout(round int32) time.Duration
- func (consensus *ConsensusTBFTImpl) ProposeTimeout(round int32) time.Duration
- func (consensus *ConsensusTBFTImpl) Start() error
- func (consensus *ConsensusTBFTImpl) StartConsistentEngine() error
- func (consensus *ConsensusTBFTImpl) Stop() error
- func (consensus *ConsensusTBFTImpl) ToGossipStateProto() *tbftpb.GossipState
- func (consensus *ConsensusTBFTImpl) ToProto() *tbftpb.ConsensusState
- func (consensus *ConsensusTBFTImpl) Type() int8
- func (consensus *ConsensusTBFTImpl) Update(state consistent_service.Status)
- func (consensus *ConsensusTBFTImpl) Verify(consensusType consensuspb.ConsensusType, chainConfig *config.ChainConfig) error
- type DeleteTxInfo
- type FEGossipState
- type FEMsgType
- type FEProposalByte
- type FERoundQC
- type FEVote
- type FEVoteByte
- type FlexEndorse
- type FlexEndorseMsg
- type FlexEndorseResult
- type FlexEndorseState
- type FlexEndorseTBFTImpl
- type ModifiedTxBatchInfo
- type NewHeightMsg
- type Node
- type RemoteState
- type ReservedTxInfo
- type StatusBroadcaster
- func (tsb *StatusBroadcaster) ID() string
- func (tsb *StatusBroadcaster) IsRunning() bool
- func (tsb *StatusBroadcaster) PreBroadcaster() consistent_service.Broadcast
- func (tsb *StatusBroadcaster) Start() error
- func (tsb *StatusBroadcaster) Stop() error
- func (tsb *StatusBroadcaster) TimePattern() interface{}
- type StatusDecoder
- type StatusInterceptor
- type TBFTProposal
- type TbftConsistentMessage
- func (m *TbftConsistentMessage) OnMessage(message *msgbus.Message)
- func (m *TbftConsistentMessage) OnQuit()
- func (m *TbftConsistentMessage) Receive() interface{}
- func (m *TbftConsistentMessage) Send(payload interface{})
- func (m *TbftConsistentMessage) Start() error
- func (m *TbftConsistentMessage) Stop() error
- type VerifyRefMsg
- type VoteSet
- func NewVoteSet(logger protocol.Logger, voteType tbftpb.VoteType, height uint64, round int32, ...) *VoteSet
- func NewVoteSetFromProto(logger protocol.Logger, vsProto *tbftpb.VoteSet, feVotes map[string]*FEVote, ...) *VoteSet
- func VerifyQcFromVotes(logger protocol.Logger, vs []*FEVote, ac protocol.AccessControlProvider, ...) (*VoteSet, error)
- func (vs *VoteSet) AddVote(feVote *FEVote, countInvalidTx bool) (added bool, err error)
- func (vs *VoteSet) AddVoteForConsistent(feVote *FEVote) (added bool, err error)
- func (vs *VoteSet) HasTwoThirdsMajority() (majority bool)
- func (vs *VoteSet) Size() int32
- func (vs *VoteSet) String() string
- func (vs *VoteSet) ToProto() *tbftpb.VoteSet
- type VoteSetByte
Constants ¶
const ( // DefaultTimeoutPropose Timeout of waitting for a proposal before prevoting nil DefaultTimeoutPropose = 30 * time.Second // DefaultTimeoutProposeDelta Increased time delta of TimeoutPropose between rounds DefaultTimeoutProposeDelta = 1 * time.Second // DefaultBlocksPerProposer The number of blocks each proposer can propose DefaultBlocksPerProposer = uint64(1) // DefaultTimeoutProposeOptimal optimal timeout of waitting for a proposal before prevoting nil DefaultTimeoutProposeOptimal = 2 * time.Second // TimeoutPrevote Timeout of waiting for >2/3 prevote TimeoutPrevote = 30 * time.Second // TimeoutPrevoteDelta Increased time delta of TimeoutPrevote between round TimeoutPrevoteDelta = 1 * time.Second // TimeoutPrecommit Timeout of waiting for >2/3 precommit TimeoutPrecommit = 30 * time.Second // TimeoutPrecommitDelta Increased time delta of TimeoutPrecommit between round TimeoutPrecommitDelta = 1 * time.Second // TimeoutCommit Timeout to wait for precommite TimeoutCommit = 30 * time.Second // TimeDisconnet the duration of node disconnectio(3000ms) TimeDisconnet = 3000 // GaugeTypeHeight is the height type for the metrics of prometheus GaugeTypeHeight = 0 // GaugeTypeRound is the round type for the metrics of prometheus GaugeTypeRound = 1 // ChainId is metrics label of chainId ChainId = "chainId" // LocalId is metrics label of localId LocalId = "localId" // NodeId is metrics label of nodeId NodeId = "nodeId" )
const ( // TimeoutEndorse Timeout of waiting for enough signatures satisfying endorsement policy TimeoutEndorse = 60 * time.Second // TimeoutEndorseDelta Increased time delta of TimeoutEndorse between round TimeoutEndorseDelta = 1 * time.Second )
const ( // TypeRemoteTBFTState is the state of remote nodes TypeRemoteTBFTState = 1 // TypeLocalTBFTState is the state of local node TypeLocalTBFTState = 2 )
const ( // MessageBufferSize 缓存消息大小 MessageBufferSize = 10240 // StatusBroadcasterTbft TBFT状态广播器ID StatusBroadcasterTbft = "TBFT" // InterceptorTbft 标识 InterceptorTbft = 0 )
Variables ¶
var ( // TBFTAddtionalDataKey implements the block key for store tbft infos TBFTAddtionalDataKey = "TBFTAddtionalDataKey" // TBFT_propose_timeout_key implements the config key for chainconf TBFT_propose_timeout_key = "TBFT_propose_timeout" // TBFT_propose_delta_timeout_key implements the config key for chainconf TBFT_propose_delta_timeout_key = "TBFT_propose_delta_timeout" // TBFT_blocks_per_proposer implements the config key for chainconf TBFT_blocks_per_proposer = "TBFT_blocks_per_proposer" // TBFT_propose_timeout_optimal_key implements the config key for chainconf TBFT_propose_timeout_optimal_key = "TBFT_propose_timeout_optimal" // TBFT_propose_optimal_key implements the config key for chainconf TBFT_propose_optimal_key = "TBFT_propose_optimal" // ProposeHashEnabledKey implements the config key for chainconf ProposeHashEnabledKey = "propose_hash_enabled" // ModifiedTxBatchInfoKey implements the block key for store modified tx batch infos ModifiedTxBatchInfoKey = "ModifiedTxBatchInfoKey" // ExecuteOptimalEnabledKey implements the config key for chainconf ExecuteOptimalEnabledKey = "execute_optimal_enabled" // ReservedTxInfoKey implements the block key for store reserved (not re-executed) tx info ReservedTxInfoKey = "ReservedTxInfoKey" )
var ( DefaultNilTx = "NilTx_" DeletedTxId = "DelTx_" )
var ( // ErrVoteNil implements the error of nil vote ErrVoteNil = errors.New("nil vote") // ErrUnexceptedStep implements the error of unexpected step in tbft ErrUnexceptedStep = errors.New("unexpected step") // ErrInvalidValidator implements the error of nil invalid validator ErrInvalidValidator = errors.New("invalid validator") // ErrVoteForDifferentHash implements the error of invalid hash ErrVoteForDifferentHash = errors.New("vote for different hash") )
var ( // ErrInvalidIndex implements the error for invalid index of validators ErrInvalidIndex = errors.New("invalid index") )
var TimerInterval = 1000 * time.Millisecond
TimerInterval 定时器间隔
Functions ¶
func CopyBlock ¶
CopyBlock generates a new block with a old block, internally using the same pointer
func CopyProposalWithBlockHeader ¶
CopyProposalWithBlockHeader create a new Proposal instance for sign and verify
func GetValidatorList ¶
func GetValidatorList(chainConfig *config.ChainConfig, store protocol.BlockchainStore) (validators []string, err error)
GetValidatorList get Validator List From Config @param chainConfig @param store Not currently in use @return validators @return err
func GetValidatorListFromConfig ¶
func GetValidatorListFromConfig(chainConfig *config.ChainConfig) (validators []string, err error)
GetValidatorListFromConfig get Validator List From Config @param chainConfig @return validators @return err
func InitLWS ¶
func InitLWS(config *config.ConsensusConfig, chainId, nodeId string) (lwsInstance *lws.Lws, walWriteMode wal_service.WalWriteMode, err error)
InitLWS initialize LWS @param config Consensus Config @param chainId @param nodeId @return lwsInstance @return walWriteMode @return err
func MarshalTBFTProposalFE ¶
func MarshalTBFTProposalFE(tbftProposal *TBFTProposal)
func NewProposal ¶
func NewProposal(voter string, height uint64, round int32, polRound int32, block *common.Block) *tbftpb.Proposal
NewProposal create a new Proposal
func NewProposalBlock ¶
func NewProposalBlock(block *common.Block, txsRwSet map[string]*common.TxRWSet) *consensuspb.ProposalBlock
NewProposalBlock create a new ProposalBlock
func NewVote ¶
func NewVote(typ tbftpb.VoteType, voter string, height uint64, round int32, hash []byte) *tbftpb.Vote
NewVote create a new Vote instance
func VerifyBlockSignatures ¶
func VerifyBlockSignatures(chainConf protocol.ChainConf, ac protocol.AccessControlProvider, block *common.Block, store protocol.BlockchainStore, validatorListFunc consensus_utils.ValidatorListFunc) error
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.
func VerifyRoundQc ¶
func VerifyRoundQc(logger protocol.Logger, ac protocol.AccessControlProvider, validators *validatorSet, feRoundQC *FERoundQC, blockVersion uint32) error
VerifyRoundQc verifies whether the signatures in roundQC verify that the Qc is nil hash and the maj32 of the voteSet error when verify successfully, and return corresponding error when failed.
Types ¶
type BlockFEVotes ¶
func NewBlockFEVotes ¶
func NewBlockFEVotes() *BlockFEVotes
type BlockVotes ¶
BlockVotes traces the vote from different voter
func NewBlockVotes ¶
func NewBlockVotes() *BlockVotes
NewBlockVotes creates a new BlockVotes instance
func (*BlockVotes) ToProto ¶
func (bv *BlockVotes) ToProto() *tbftpb.BlockVotes
ToProto serializes the BlockVotes instance
type ConsensusFutureMsg ¶
type ConsensusFutureMsg struct {
// Proposal map[int32]*tbftpb.Proposal
Proposal map[int32]*TBFTProposal
// contains filtered or unexported fields
}
ConsensusFutureMsg represents the consensus msg of future
type ConsensusFutureMsgCache ¶
type ConsensusFutureMsgCache struct {
// contains filtered or unexported fields
}
ConsensusFutureMsgCache cache future consensus msg
type ConsensusMsg ¶
type ConsensusMsg struct {
Type tbftpb.TBFTMsgType
Msg interface{}
}
ConsensusMsg implements transformation of structure and pb
type ConsensusState ¶
type ConsensusState struct {
// node id
Id string
// current height
Height uint64
// current round
Round int32
// current step
Step tbftpb.Step
// proposal
Proposal *TBFTProposal
// verifing proposal
VerifingProposal *TBFTProposal
LockedRound int32
// locked proposal
// LockedProposal *tbftpb.Proposal
LockedProposal *TBFTProposal
ValidRound int32
// valid proposal
// ValidProposal *tbftpb.Proposal
ValidProposal *TBFTProposal
// contains filtered or unexported fields
}
ConsensusState represents the consensus state of the node
func NewConsensusState ¶
func NewConsensusState(logger protocol.Logger, id string) *ConsensusState
NewConsensusState creates a new ConsensusState instance
type ConsensusTBFTImpl ¶
type ConsensusTBFTImpl struct {
sync.RWMutex
// node id
Id string
// Current Consensus State
*ConsensusState
// Timeout = TimeoutPropose + TimeoutProposeDelta * round
TimeoutPropose time.Duration
TimeoutProposeDelta time.Duration
TimeoutProposeOptimal time.Duration
ProposeOptimal bool
ProposeOptimalTimer *time.Timer
// contains filtered or unexported fields
}
ConsensusTBFTImpl is the implementation of TBFT algorithm and it implements the ConsensusEngine interface.
func New ¶
func New(config *consensusUtils.ConsensusImplConfig) (*ConsensusTBFTImpl, error)
New creates a tbft consensus instance
func (*ConsensusTBFTImpl) AddTimeout ¶
func (consensus *ConsensusTBFTImpl) AddTimeout(duration time.Duration, height uint64, round int32, step tbftpb.Step)
AddTimeout adds timeout event to timeScheduler
func (*ConsensusTBFTImpl) CommitTimeout ¶
func (consensus *ConsensusTBFTImpl) CommitTimeout(round int32) time.Duration
CommitTimeout returns timeout to wait for precommiting at `round`
func (*ConsensusTBFTImpl) Data ¶
func (consensus *ConsensusTBFTImpl) Data() interface{}
Data return Status Data(ConsistentEngine) @receiver consensus @return interface{}
func (*ConsensusTBFTImpl) GetConsensusStateJSON ¶
func (consensus *ConsensusTBFTImpl) GetConsensusStateJSON() ([]byte, error)
GetConsensusStateJSON get consensus status in json format @receiver consensus @return []byte @return error always return nil
func (*ConsensusTBFTImpl) GetLastHeight ¶
func (consensus *ConsensusTBFTImpl) GetLastHeight() uint64
GetLastHeight get current height from consensus state @receiver consensus @return uint64
func (*ConsensusTBFTImpl) GetValidators ¶
func (consensus *ConsensusTBFTImpl) GetValidators() ([]string, error)
GetValidators get validators from consensus state GetValidators get validators from consensus state @receiver consensus @return []string validators @return error always return nil
func (*ConsensusTBFTImpl) InitConsistentEngine ¶
func (consensus *ConsensusTBFTImpl) InitConsistentEngine()
InitConsistentEngine init ConsistentEngine @receiver consensus
func (*ConsensusTBFTImpl) InitExtendHandler ¶
func (consensus *ConsensusTBFTImpl) InitExtendHandler(handler protocol.ConsensusExtendHandler)
InitExtendHandler r egistered extendHandler
func (*ConsensusTBFTImpl) NewGaugeVec ¶
func (consensus *ConsensusTBFTImpl) NewGaugeVec(nodeId string, gaugeType int)
NewGaugeVec builds a height or round gauge vec for prometheus
func (*ConsensusTBFTImpl) OnMessage ¶
func (consensus *ConsensusTBFTImpl) OnMessage(message *msgbus.Message)
OnMessage implements the OnMessage method of msgbus.
func (*ConsensusTBFTImpl) OnQuit ¶
func (consensus *ConsensusTBFTImpl) OnQuit()
OnQuit implements the OnQuit method of msgbus.
func (*ConsensusTBFTImpl) PrecommitTimeout ¶
func (consensus *ConsensusTBFTImpl) PrecommitTimeout(round int32) time.Duration
PrecommitTimeout returns timeout to wait for precommiting at `round`
func (*ConsensusTBFTImpl) PrevoteTimeout ¶
func (consensus *ConsensusTBFTImpl) PrevoteTimeout(round int32) time.Duration
PrevoteTimeout returns timeout to wait for prevoting at `round`
func (*ConsensusTBFTImpl) ProposeTimeout ¶
func (consensus *ConsensusTBFTImpl) ProposeTimeout(round int32) time.Duration
ProposeTimeout returns timeout to wait for proposing at `round`
func (*ConsensusTBFTImpl) Start ¶
func (consensus *ConsensusTBFTImpl) Start() error
Start starts the tbft instance with: 1. Register to message bus for subscribing topics 2. Start background goroutinues for processing events 3. Start timeScheduler for processing timeout shedule the consensus module monitors the signal of the sync module, when the sync module synchronizes a relatively high block, it notifies the consensus module to start the consensus process
func (*ConsensusTBFTImpl) StartConsistentEngine ¶
func (consensus *ConsensusTBFTImpl) StartConsistentEngine() error
StartConsistentEngine start consistent engine @Description: Start ConsistentEngine @receiver consensus
func (*ConsensusTBFTImpl) Stop ¶
func (consensus *ConsensusTBFTImpl) Stop() error
Stop implements the Stop method of ConsensusEngine interface.
func (*ConsensusTBFTImpl) ToGossipStateProto ¶
func (consensus *ConsensusTBFTImpl) ToGossipStateProto() *tbftpb.GossipState
ToGossipStateProto convert *ConsensusTBFTImpl to *tbftpb.GossipState @receiver consensus @return *tbftpb.GossipState
func (*ConsensusTBFTImpl) ToProto ¶
func (consensus *ConsensusTBFTImpl) ToProto() *tbftpb.ConsensusState
ToProto copy *ConsensusState to *tbftpb.ConsensusState @receiver consensus @return *tbftpb.ConsensusState
func (*ConsensusTBFTImpl) Type ¶
func (consensus *ConsensusTBFTImpl) Type() int8
Type return Status Type(ConsistentEngine) @receiver consensus @return int
func (*ConsensusTBFTImpl) Update ¶
func (consensus *ConsensusTBFTImpl) Update(state consistent_service.Status)
Update update state @receiver consensus @param state
func (*ConsensusTBFTImpl) Verify ¶
func (consensus *ConsensusTBFTImpl) 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.
type DeleteTxInfo ¶
type DeleteTxInfo struct {
Tx *common.Transaction
Precommits *VoteSet
}
type FEGossipState ¶
type FEGossipState struct {
State *tbftpb.GossipState
FEPrevotes *VoteSetByte
FEPrecommits *VoteSetByte
}
type FEMsgType ¶
type FEMsgType int32
const ( FEMsgType_MSG_PROPOSE FEMsgType = 0 FEMsgType_MSG_PREVOTE FEMsgType = 1 FEMsgType_MSG_PRECOMMIT FEMsgType = 2 FEMsgType_MSG_VERIFY_REF FEMsgType = 3 FEMsgType_MSG_STATE FEMsgType = 4 FEMsgType_MSG_TIMEOUT FEMsgType = 5 FEMsgType_MSG_ENDORSE_RES FEMsgType = 6 FEMsgType_MSG_UPDATE_REF FEMsgType = 7 FEMsgType_MSG_ALLONE FEMsgType = 8 )
type FEProposalByte ¶
type FEProposalByte struct {
// flexible endorsement: refRound
RefRound int32
// signature
Endorsement *common.EndorsementEntry
// QC: []*FEVote
Qc []*FEVote
// byte format *tbftpb.Proposal
Bytes []byte
}
type FERoundQC ¶
type FEVote ¶
type FEVote struct {
// original tbft vote
Vote *tbftpb.Vote
// flexible endorsement:
// PREVOTE --> approval
// PRECOMMIT --> result
OpposedTxs map[int]struct{}
// signature
Endorsement *common.EndorsementEntry
}
Flexible Endorsement Vote
type FEVoteByte ¶
type FEVoteByte struct {
// flexible endorsement
OpposedTxs map[int]struct{}
// signature
Endorsement *common.EndorsementEntry
// byte format *tbftpb.Vote
Bytes []byte
}
type FlexEndorse ¶
type FlexEndorseResult ¶
type FlexEndorseTBFTImpl ¶
type FlexEndorseTBFTImpl struct {
// contains filtered or unexported fields
}
func NewFlexEndorseTBFTImpl ¶
func NewFlexEndorseTBFTImpl(logger protocol.Logger, id string, consensusMsgC chan *FlexEndorseMsg, flexEndorseMsgC chan *FlexEndorseMsg, feApprovedPrevoteC chan *FEVote) *FlexEndorseTBFTImpl
NewFlexEndorseTBFTImpl creates and initializes a new instance of FlexEndorseTBFTImpl.
Parameters:
- logger: the logger interface used for internal logging
- id: unique identifier of this node
- consensusMsgC: channel receiving messages from the consensus layer
- flexEndorseMsgC: channel sending messages back to consensus
- feApprovedPrevoteC: channel used to send approved prevote results
It initializes internal components like the time scheduler and contract analyzer, and returns a fully constructed *FlexEndorseTBFTImpl instance ready to Start().
func (*FlexEndorseTBFTImpl) AddTimeout ¶
func (flexEndorse *FlexEndorseTBFTImpl) AddTimeout(duration time.Duration, height uint64, round int32)
AddTimeout registers a timeout event for a given height/round combination. This timeout is used by the consensus scheduler to trigger future events automatically.
func (*FlexEndorseTBFTImpl) EndorseTimeout ¶
func (flexEndorse *FlexEndorseTBFTImpl) EndorseTimeout(round int32) time.Duration
EndorseTimeout computes the dynamic endorsement timeout for a given round.
The timeout increases linearly with each round based on TimeoutEndorseDelta, providing adaptive delay control as the round progresses.
func (*FlexEndorseTBFTImpl) Start ¶
func (flexEndorse *FlexEndorseTBFTImpl) Start()
Start launches the flexible endorsement process. It starts the internal time scheduler and spins up the main message handling goroutine.
func (*FlexEndorseTBFTImpl) Stop ¶
func (flexEndorse *FlexEndorseTBFTImpl) Stop()
Stop terminates the endorsement process gracefully. It stops the time scheduler and signals the handler loop to exit.
type ModifiedTxBatchInfo ¶
type Node ¶
Node 节点信息(local/remoter)
func (*Node) Statuses ¶
func (l *Node) Statuses() map[int8]consistent_service.Status
Statuses 返回节点状态
func (*Node) UpdateStatus ¶
func (l *Node) UpdateStatus(s consistent_service.Status)
UpdateStatus 更新节点状态
type RemoteState ¶
type RemoteState struct {
sync.RWMutex
//node id
Id string
//current height
Height uint64
// current round
Round int32
// current step
Step tbftpb.Step
// proposal
Proposal []byte
VerifingProposal []byte
LockedRound int32
// locked proposal
LockedProposal *tbftpb.Proposal
ValidRound int32
// valid proposal
ValidProposal *tbftpb.Proposal
RoundVoteSet *roundVoteSet
}
RemoteState validator status, validator and remote are the same
func (*RemoteState) Update ¶
func (r *RemoteState) Update(state consistent_service.Status)
Update 更新远端节点的状态
type StatusBroadcaster ¶
type StatusBroadcaster struct {
// contains filtered or unexported fields
}
StatusBroadcaster 一致性引擎的状态和消息的broadcaster实现
func NewTBFTStatusBroadcaster ¶
func NewTBFTStatusBroadcaster(log protocol.Logger) *StatusBroadcaster
NewTBFTStatusBroadcaster 得到一个broadcaster实例
func (*StatusBroadcaster) IsRunning ¶
func (tsb *StatusBroadcaster) IsRunning() bool
IsRunning 返回运行状态
func (*StatusBroadcaster) PreBroadcaster ¶
func (tsb *StatusBroadcaster) PreBroadcaster() consistent_service.Broadcast
PreBroadcaster 消息广播前做前置处理,如状态校验/判断是否要发送消息等
func (*StatusBroadcaster) TimePattern ¶
func (tsb *StatusBroadcaster) TimePattern() interface{}
TimePattern 状态广播触发模式
type StatusDecoder ¶
type StatusDecoder struct {
// contains filtered or unexported fields
}
StatusDecoder 状态解析器
func (*StatusDecoder) Decode ¶
func (tD *StatusDecoder) Decode(d interface{}) interface{}
Decode 解析消息,返回节点状态
type StatusInterceptor ¶
type StatusInterceptor struct {
}
StatusInterceptor 状态拦截器
func (*StatusInterceptor) Handle ¶
func (tsb *StatusInterceptor) Handle(status consistent_service.Status) error
Handle 过滤状态类型处理
type TBFTProposal ¶
type TBFTProposal struct {
PbMsg *tbftpb.Proposal
// flexible endorsement: refRound
RefRound int32
// signature
Endorsement *common.EndorsementEntry
// QC: []*FEVote
Qc []*FEVote
// byte format *FEProposalByte
Bytes []byte
}
TBFTProposal represents the marshaled proposal
func CloneTBFTProposal ¶
func CloneTBFTProposal(tbftProposal *TBFTProposal) *TBFTProposal
func NewTBFTProposal ¶
func NewTBFTProposal(proposal *tbftpb.Proposal, marshal bool) *TBFTProposal
NewTBFTProposal create tbft proposal instance
func NewTBFTProposalFE ¶
func NewTBFTProposalFE(proposal *tbftpb.Proposal, refRound int32) *TBFTProposal
func (*TBFTProposal) Marshal ¶
func (p *TBFTProposal) Marshal()
Marshal marshal the proposal and not care the old bytes
type TbftConsistentMessage ¶
type TbftConsistentMessage struct {
// contains filtered or unexported fields
}
TbftConsistentMessage 实现一致性引擎消息的接收和发送
func NewTbftConsistentMessage ¶
func NewTbftConsistentMessage(msgBus msgbus.MessageBus, log consistent_service.Logger) *TbftConsistentMessage
NewTbftConsistentMessage 初始化得到一致性引擎消息处理实例
func (*TbftConsistentMessage) OnMessage ¶
func (m *TbftConsistentMessage) OnMessage(message *msgbus.Message)
OnMessage 基于msgbus的实现
func (*TbftConsistentMessage) Receive ¶
func (m *TbftConsistentMessage) Receive() interface{}
Receive 接收一致性引擎的消息
func (*TbftConsistentMessage) Send ¶
func (m *TbftConsistentMessage) Send(payload interface{})
Send 发送一致性引擎的消息
type VerifyRefMsg ¶
type VerifyRefMsg struct {
Proposal *TBFTProposal
RefRound int32
Time time.Time
Valid bool
}
type VoteSet ¶
type VoteSet struct {
Type tbftpb.VoteType
Height uint64
Round int32
Sum uint64
Maj23 []byte
Votes map[string]*tbftpb.Vote
VotesByBlock map[string]*BlockVotes
// flexible endorsement
FEVotes map[string]*FEVote
FEVotesByBlock map[string]*BlockFEVotes
// contains filtered or unexported fields
}
VoteSet wraps tbftpb.VoteSet and validatorSet
func NewVoteSet ¶
func NewVoteSet(logger protocol.Logger, voteType tbftpb.VoteType, height uint64, round int32, validators *validatorSet) *VoteSet
NewVoteSet creates a new VoteSet instance
func NewVoteSetFromProto ¶
func NewVoteSetFromProto(logger protocol.Logger, vsProto *tbftpb.VoteSet, feVotes map[string]*FEVote, validators *validatorSet) *VoteSet
NewVoteSetFromProto creates a new VoteSet instance from pb func NewVoteSetFromProto(logger protocol.Logger, vsProto *tbftpb.VoteSet, validators *validatorSet) *VoteSet {
func VerifyQcFromVotes ¶
func VerifyQcFromVotes(logger protocol.Logger, vs []*FEVote, ac protocol.AccessControlProvider, validators *validatorSet, voteType tbftpb.VoteType, blockVersion uint32) (*VoteSet, error)
VerifyQcFromVotes verifies whether the signatures in votes verify that the maj32 of the votes error when verify successfully, and return corresponding error when failed. func VerifyQcFromVotes(logger protocol.Logger, vs []*tbftpb.Vote, ac protocol.AccessControlProvider,
func (*VoteSet) AddVote ¶
AddVote adds a vote to the VoteSet
func (*VoteSet) AddVoteForConsistent ¶
AddVoteForConsistent adds a vote to the VoteSet
func (*VoteSet) HasTwoThirdsMajority ¶
HasTwoThirdsMajority shoule used when the mutex has been lock
Source Files
¶
- consensus_msg.go
- consensus_tbft_impl.go
- flexendorse_tbft_impl.go
- metrics.go
- state.go
- tbft_msg.go
- tbft_status.go
- tbft_status_broadcaster.go
- timesched.go
- utils.go
- validator.go
- vote.go