network

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResolvingTimeDuration = time.Second // 1 second.
	StateMax              = 1000        //max size for status
	StateClear            = 500
)

Variables

This section is empty.

Functions

func LogMsg

func LogMsg(msg interface{})

func LogStage

func LogStage(stage string, isDone bool)

func PrintNode

func PrintNode(node *Node)

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

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

func (*Node) BroadcastOne

func (node *Node) BroadcastOne(msg interface{}, path string, node_id string) (err error)

func (*Node) ClearStatus

func (node *Node) ClearStatus(height int64)

func (*Node) CommitWaitQueuePush

func (node *Node) CommitWaitQueuePush(msg *consensus.VoteMsg)

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

func (node *Node) GetStatus(height int64) *consensus.State

func (*Node) PutStatus

func (node *Node) PutStatus(height int64, state *consensus.State)

func (*Node) Reply

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

func (*Node) ReplyResult

func (node *Node) ReplyResult(msgHeight int64)

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)

func (*Server) Start

func (server *Server) Start(work func(cid *big.Int, acChan <-chan *consensus.ActionIn))

func (*Server) Stop

func (server *Server) Stop()

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