Documentation
¶
Index ¶
- Constants
- func LogMsg(msg interface{})
- func LogStage(stage string, isDone bool)
- func PrintNode(node *Node)
- type MsgBuffer
- type Node
- func (node *Node) Broadcast(msg interface{}, path string) map[string]error
- func (node *Node) BroadcastOne(msg interface{}, path string, node_id string) (err error)
- func (node *Node) ClearStatus(height int64)
- func (node *Node) CommitWaitQueuePush(msg *consensus.VoteMsg)
- func (node *Node) GetCommit(commitMsg *consensus.VoteMsg) error
- func (node *Node) GetPrePrepare(prePrepareMsg *consensus.PrePrepareMsg) error
- func (node *Node) GetPrepare(prepareMsg *consensus.VoteMsg) error
- func (node *Node) GetReply(msg *consensus.ReplyMsg)
- func (node *Node) GetReq(reqMsg *consensus.RequestMsg) error
- func (node *Node) GetStatus(height int64) *consensus.State
- func (node *Node) PutStatus(height int64, state *consensus.State)
- func (node *Node) Reply(msg *consensus.ReplyMsg) error
- func (node *Node) ReplyResult(msgHeight int64)
- func (node *Node) UpdateStatus(msg *consensus.RequestMsg)
- type Server
- type View
Constants ¶
View Source
const ( ResolvingTimeDuration = time.Second // 1 second. StateMax = 1000 //max size for status StateClear = 500 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MsgBuffer ¶
type MsgBuffer struct {
ReqMsgs []*consensus.RequestMsg
PrePrepareMsgs []*consensus.PrePrepareMsg
PrepareMsgs []*consensus.VoteMsg
CommitMsgs []*consensus.VoteMsg
}
type Node ¶
type Node struct {
NodeID string
NodeTable map[string]string // key=nodeID, value=url
NTLock sync.RWMutex
View *View
States map[int64]*consensus.State
CommittedMsgs []*consensus.RequestMsg // kinda block.
CommitWaitQueue *prque.Prque
CWLock sync.Mutex
MsgBuffer *MsgBuffer
MsgEntrance chan interface{}
MsgDelivery chan interface{}
MsgBackward chan interface{}
Alarm chan bool
FinishChan chan int64
Verify consensus.ConsensusVerify
Finish consensus.ConsensusFinish
ID *big.Int
PrePareLock sync.Mutex
CommitLock sync.Mutex
CurrentHeight int64
RetryPrePrepareMsg map[int64]*consensus.PrePrepareMsg
Stop bool
// contains filtered or unexported fields
}
func NewNode ¶
func NewNode(nodeID string, verify consensus.ConsensusVerify, finish consensus.ConsensusFinish, addrs []*types.CommitteeNode, id *big.Int) *Node
func (*Node) BroadcastOne ¶
func (*Node) ClearStatus ¶
func (*Node) CommitWaitQueuePush ¶
func (*Node) GetPrePrepare ¶
func (node *Node) GetPrePrepare(prePrepareMsg *consensus.PrePrepareMsg) error
GetPrePrepare can be called when the node's CurrentState is nil. Consensus start procedure for normal participants.
func (*Node) GetReq ¶
func (node *Node) GetReq(reqMsg *consensus.RequestMsg) error
GetReq can be called when the node's CurrentState is nil. Consensus start procedure for the Primary.
func (*Node) ReplyResult ¶
func (*Node) UpdateStatus ¶
func (node *Node) UpdateStatus(msg *consensus.RequestMsg)
type Server ¶
type Server struct {
Node *Node
ID *big.Int
ActionChan chan *consensus.ActionIn
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(nodeID string, id *big.Int, help consensus.ConsensusHelp, verify consensus.ConsensusVerify, addrs []*types.CommitteeNode) *Server
func (*Server) ConsensusFinish ¶
func (server *Server) ConsensusFinish()
func (*Server) PutRequest ¶
func (server *Server) PutRequest(msg *consensus.RequestMsg)
Click to show internal directories.
Click to hide internal directories.