Documentation ¶
Overview ¶
TODO: secure connection such as HTTPS, or manual implementation from Section 5.2.2 Key Exchanges on TOCS.
Index ¶
- Constants
- func GetPrePrepareForNewview(nextviewID int64, sequenceid int64, digest string) *consensus.PrePrepareMsg
- func LogMsg(msg interface{})
- func LogStage(stage string, isDone bool)
- func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request)
- type Client
- type Hub
- type MsgOut
- type MsgPair
- type Node
- func (node *Node) Broadcast(msg interface{}, path string)
- func (node *Node) CheckPoint(msg *consensus.CheckPointMsg)
- func (node *Node) CheckPointMissCheck(sequenceID int64) bool
- func (node *Node) Checkpointchk(state consensus.PBFT) bool
- func (node *Node) CreateSetP() map[int64]*consensus.SetPm
- func (node *Node) CreateViewChangeMsg(setp map[int64]*consensus.SetPm) *consensus.ViewChangeMsg
- func (node *Node) FillHole(newviewMsg *consensus.NewViewMsg)
- func (node *Node) GetCheckPoint(CheckPointMsg *consensus.CheckPointMsg) error
- func (node *Node) GetCommit(state consensus.PBFT, commitMsg *consensus.VoteMsg)
- func (node *Node) GetNewView(newviewMsg *consensus.NewViewMsg) error
- func (node *Node) GetPrePrepare(state consensus.PBFT, prePrepareMsg *consensus.PrePrepareMsg)
- func (node *Node) GetPrepare(state consensus.PBFT, prepareMsg *consensus.VoteMsg)
- func (node *Node) GetReply(msg *consensus.ReplyMsg)
- func (node *Node) GetReq(reqMsg *consensus.RequestMsg)
- func (node *Node) GetViewChange(viewchangeMsg *consensus.ViewChangeMsg)
- func (node *Node) StartViewChange()
- type NodeInfo
- type Server
- type View
Constants ¶
const ConsensusDeadline = time.Millisecond * 100
Deadline for the consensus state.
const CoolingTime = time.Millisecond * 2
Cooling time to escape frequent error, or message sending retry.
const CoolingTotalErrMsg = 5
Number of error messages to start cooling.
const MaxOutboundConnection = 1000
Number of outbound connection for a node.
const NumResolveMsgGo = 6
Number of parallel goroutines for resolving messages.
Variables ¶
This section is empty.
Functions ¶
func GetPrePrepareForNewview ¶
func GetPrePrepareForNewview(nextviewID int64, sequenceid int64, digest string) *consensus.PrePrepareMsg
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub maintains the set of active clients and broadcasts messages to the clients.
type Node ¶
type Node struct { MyInfo *NodeInfo PrivKey *ecdsa.PrivateKey NodeTable []*NodeInfo View *View States map[int64]consensus.PBFT // key: sequenceID, value: state VCStates map[int64]*consensus.VCState CommittedMsgs []*consensus.RequestMsg // kinda block. TotalConsensus int64 // atomic. number of consensus started so far. IsViewChanging bool // Channels MsgEntrance chan interface{} MsgDelivery chan interface{} MsgExecution chan *MsgPair MsgOutbound chan *MsgOut MsgError chan []error ViewMsgEntrance chan interface{} // Mutexes for preventing from concurrent access StatesMutex sync.RWMutex VCStatesMutex sync.RWMutex // Saved checkpoint messages on this node // key: sequenceID, value: map(key: nodeID, value: checkpointMsg) CheckPointMutex sync.RWMutex CheckPointMsgsLog map[int64]map[string]*consensus.CheckPointMsg // The stable checkpoint that 2f + 1 nodes agreed StableCheckPoint int64 }
func (*Node) CheckPoint ¶
func (node *Node) CheckPoint(msg *consensus.CheckPointMsg)
func (*Node) CheckPointMissCheck ¶
Check the COMMIT messages, for given `periodCheckPoint` consecutive sequence numbers, are enough including the messages for the current node.
func (*Node) Checkpointchk ¶
Check the CHECKPOINT messages for given sequence number are enough including the message for the current node.
func (*Node) CreateSetP ¶
Create a set of PreprepareMsg and PrepareMsgs for each sequence number.
func (*Node) CreateViewChangeMsg ¶
func (*Node) FillHole ¶
func (node *Node) FillHole(newviewMsg *consensus.NewViewMsg)
func (*Node) GetCheckPoint ¶
func (node *Node) GetCheckPoint(CheckPointMsg *consensus.CheckPointMsg) error
func (*Node) GetNewView ¶
func (node *Node) GetNewView(newviewMsg *consensus.NewViewMsg) error
func (*Node) GetPrePrepare ¶
func (node *Node) GetPrePrepare(state consensus.PBFT, prePrepareMsg *consensus.PrePrepareMsg)
func (*Node) GetPrepare ¶
func (*Node) GetReq ¶
func (node *Node) GetReq(reqMsg *consensus.RequestMsg)
When REQUEST message is broadcasted, start consensus.
func (*Node) GetViewChange ¶
func (node *Node) GetViewChange(viewchangeMsg *consensus.ViewChangeMsg)
func (*Node) StartViewChange ¶
func (node *Node) StartViewChange()