Documentation ¶
Index ¶
- type LogBlockCollection
- type LogGroupBySigner
- type LogGroupByType
- type LogMessage
- type LogMsgCollection
- type MsgManager
- type MsgQueue
- type PBFT
- func (pbft *PBFT) AddBroadcastTask(msg *StateMsg)
- func (pbft *PBFT) AppendMsg(msg *model.PbftMessage) bool
- func (pbft *PBFT) ApplyBlock(block *model.PbftBlock) error
- func (pbft *PBFT) BroadcastMsgRoutine()
- func (pbft *PBFT) ChangeState(s model.States)
- func (pbft *PBFT) CommitBlock(block *model.PbftBlock) error
- func (pbft *PBFT) CompareStateMsg(a *StateMsg, b *StateMsg) bool
- func (pbft *PBFT) CurrentState() model.States
- func (pbft *PBFT) Daemon()
- func (pbft *PBFT) FindBlock(num, view uint64) *model.PbftBlock
- func (pbft *PBFT) FindStateMsg(num, view uint64, msgType model.MessageType) []*StateMsg
- func (pbft *PBFT) FindStateMsgBySinger(num, view uint64, msgType model.MessageType, signer []byte) *StateMsg
- func (pbft *PBFT) GetMsgSigner(msg *model.PbftMessage) []byte
- func (pbft *PBFT) IsPrimaryVerfier() bool
- func (pbft *PBFT) IsVaildVerifier(singerID []byte) bool
- func (pbft *PBFT) SignMsg(msg *model.PbftMessage) (*model.PbftMessage, error)
- func (pbft *PBFT) Start()
- func (pbft *PBFT) StartAPI(g *echo.Group)
- func (pbft *PBFT) StateMigrate(msg *model.PbftMessage)
- func (pbft *PBFT) Stop()
- func (pbft *PBFT) TryApplyBlock(block *model.PbftBlock) error
- func (pbft *PBFT) VerfifyBlockHeader(blk *model.PbftBlock) bool
- func (pbft *PBFT) VerfifyGenesisBlock(blk *model.PbftBlock) bool
- func (pbft *PBFT) VerfifyMostBlock(blk *model.PbftBlock) bool
- func (pbft *PBFT) VerfifyMsg(msg *model.PbftMessage) bool
- type StateMachine
- type StateMsg
- type StatePollingTimer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogBlockCollection ¶
blknum: { singerpairs: block }
func (LogBlockCollection) FindBlock ¶
func (lm LogBlockCollection) FindBlock(num uint64) map[int]*model.PbftBlock
func (LogBlockCollection) ResetBlock ¶
func (lm LogBlockCollection) ResetBlock(num uint64)
type LogGroupBySigner ¶
type LogGroupBySigner map[string]LogMessage
type LogGroupByType ¶
type LogGroupByType map[string]LogGroupBySigner
type LogMessage ¶
type LogMessage struct { model.MessageType // contains filtered or unexported fields }
type LogMsgCollection ¶
type LogMsgCollection map[uint64]LogGroupByType
func (LogMsgCollection) ExistMsgBySinger ¶
func (lm LogMsgCollection) ExistMsgBySinger(num uint64, msgType model.MessageType, view int, signer string) bool
检查被signer签名的消息是否已经收到
func (LogMsgCollection) FindMsg ¶
func (lm LogMsgCollection) FindMsg(num uint64, msgType model.MessageType, view int) LogGroupBySigner
type MsgManager ¶
type MsgManager struct { // block_num-view : blk BlockMsg map[string]*model.PbftBlock BlockMsgLock sync.RWMutex StateMsgs map[string][]*StateMsg StateMsgLock sync.RWMutex BlockView map[uint64]map[uint64]struct{} BlockViewLock sync.RWMutex }
func NewMsgManager ¶
func NewMsgManager() *MsgManager
type MsgQueue ¶
func NewMsgQueue ¶
func NewMsgQueue() *MsgQueue
func (*MsgQueue) InsertMsg ¶
func (mq *MsgQueue) InsertMsg(msg *model.PbftMessage)
func (*MsgQueue) WaitMsg ¶
func (mq *MsgQueue) WaitMsg() <-chan *model.PbftMessage
type PBFT ¶
type PBFT struct { Msgs *MsgQueue StopFlag bool sync.Mutex // contains filtered or unexported fields }
func New ¶
func New(ws *world_state.WroldState, txPool *transaction.TxPool, switcher network.SwitcherI, vm *cvm.VirtualMachine, cfg *config.Configure) (*PBFT, error)
func (*PBFT) AddBroadcastTask ¶
func (*PBFT) ApplyBlock ¶
ApplyBlock 执行区块变更
func (*PBFT) BroadcastMsgRoutine ¶
func (pbft *PBFT) BroadcastMsgRoutine()
定时广播 由于网路原因 可能会导致一些节点不能一次成功收到消息 多次进行广播
func (*PBFT) ChangeState ¶
func (*PBFT) CommitBlock ¶
CommitBlock 提交区块
func (*PBFT) CurrentState ¶
func (*PBFT) FindStateMsg ¶
func (pbft *PBFT) FindStateMsg(num, view uint64, msgType model.MessageType) []*StateMsg
func (*PBFT) FindStateMsgBySinger ¶
func (*PBFT) GetMsgSigner ¶
func (pbft *PBFT) GetMsgSigner(msg *model.PbftMessage) []byte
func (*PBFT) IsPrimaryVerfier ¶
func (*PBFT) IsVaildVerifier ¶
func (*PBFT) SignMsg ¶
func (pbft *PBFT) SignMsg(msg *model.PbftMessage) (*model.PbftMessage, error)
func (*PBFT) TryApplyBlock ¶
TryApplyBlock 尝试执行区块交易 校验接收到区块交易是否正确
func (*PBFT) VerfifyBlockHeader ¶
VerfifyBlockHeader 验证区块头 需要超过2/3f才能成功
func (*PBFT) VerfifyMostBlock ¶
VerfifyMostBlock 验证有超过2/3的节点已对区块进行了签名
func (*PBFT) VerfifyMsg ¶
func (pbft *PBFT) VerfifyMsg(msg *model.PbftMessage) bool
type StateMachine ¶
func NewStateMachine ¶
func NewStateMachine() *StateMachine
type StateMsg ¶
type StateMsg struct { MsgType model.MessageType Msg *model.PbftMessage GenericMsg *model.PbftGenericMessage ViewChangeMsg *model.PbftViewChange Signer []byte Broadcast bool // 是否被广播过 Readed bool // 是否在状态迁移阶段被读取过 sync.RWMutex // }
type StatePollingTimer ¶
func NewStatePollingTimer ¶
func NewStatePollingTimer() *StatePollingTimer
func (*StatePollingTimer) AdjustmentPolling ¶
func (st *StatePollingTimer) AdjustmentPolling(duration time.Duration)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.