network

package
v0.0.0-...-d2cd647 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2020 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ResolvingTimeDuration = time.Millisecond * 1000 // 1 second.

Variables

This section is empty.

Functions

func LogMsg

func LogMsg(msg interface{})

func LogStage

func LogStage(stage string, isDone bool)

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
	View          *View
	CurrentState  *consensus.State
	CommittedMsgs []*consensus.RequestMsg // kinda block.
	MsgBuffer     *MsgBuffer
	MsgEntrance   chan interface{}
	MsgDelivery   chan interface{}
	Alarm         chan bool
	// contains filtered or unexported fields
}

func NewNode

func NewNode(nodeID string) *Node

func (*Node) Broadcast

func (node *Node) Broadcast(msg interface{}, path string) map[string]error

func (*Node) GetCommit

func (node *Node) GetCommit(commitMsg *consensus.VoteMsg) error

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) GetPrepare

func (node *Node) GetPrepare(prepareMsg *consensus.VoteMsg) error

func (*Node) GetReply

func (node *Node) GetReply(msg *consensus.ReplyMsg)

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) LogMsg

func (node *Node) LogMsg(msg interface{})

func (*Node) LogStage

func (node *Node) LogStage(stage string, isDone bool)

func (*Node) Reply

func (node *Node) Reply(msg *consensus.ReplyMsg) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(nodeID string) *Server

func (*Server) Start

func (server *Server) Start()

type View

type View struct {
	ID      int64
	Primary string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL