messages

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NIL = MessageType(iota)
	RequestMessageType
	ProposalMessageType
	ResponseMessageType
	CommitMessageType
	SyncBlockReqMessageType
	SyncBlockRespMessageType
	ViewChangeMessageReqType
)

Variables

This section is empty.

Functions

func BroadcastPeers

func BroadcastPeers(msgPayload []byte, MessageType MessageType, digest types.Hash, peers []account.Account)

func BroadcastPeersFilter

func BroadcastPeersFilter(msgPayload []byte, MessageType MessageType, digest types.Hash, peers []account.Account, black account.Account)

func EncodeMessage

func EncodeMessage(msg Message) ([]byte, error)

EncodeMessage encode message to byte array.

func Unicast

func Unicast(account account.Account, msgPayload []byte, MessageType MessageType, digest types.Hash) error

send msg to specified destination

Types

type Commit

type Commit struct {
	Account    account.Account
	Timestamp  int64
	BlockHash  types.Hash
	Digest     types.Hash
	Signatures [][]byte
	Result     bool
}

type CommitMessage

type CommitMessage struct {
	Commit *Commit
}

commit msg

type ConsensusResult

type ConsensusResult struct {
	Signatures [][]byte
	Result     error
}

type Message

type Message struct {
	MessageType MessageType
	PayLoad     interface{}
}

func DecodeMessage

func DecodeMessage(MessageType MessageType, rawMsg []byte) (Message, error)

func ReadMessage

func ReadMessage(reader io.Reader) (Message, error)

ReadMessage read message

type MessageHeader

type MessageHeader struct {
	Magic       uint32
	MessageType MessageType
	Length      uint32
}

type MessageType

type MessageType uint32

MessageType is the message type

type Proposal

type Proposal struct {
	Id        uint64
	Timestamp int64
	Payload   *types.Block
	Signature []byte
}

type ProposalMessage

type ProposalMessage struct {
	Proposal *Proposal
}

proposal msg

type Request

type Request struct {
	Timestamp int64
	Payload   *types.Block
}

type RequestMessage

type RequestMessage struct {
	Request *Request
}

request msg

type Response

type Response struct {
	Account   account.Account
	Timestamp int64
	Digest    types.Hash
	Signature []byte
}

type ResponseMessage

type ResponseMessage struct {
	Response *Response
}

response msg

type SyncBlockReq

type SyncBlockReq struct {
	Node       account.Account
	Timestamp  int64
	BlockStart uint64
	BlockEnd   uint64
}

type SyncBlockReqMessage

type SyncBlockReqMessage struct {
	SyncBlock *SyncBlockReq
}

sync block request msg

type SyncBlockResp

type SyncBlockResp struct {
	// TODO: add signatures
	Blocks []*types.Block
}

type SyncBlockRespMessage

type SyncBlockRespMessage struct {
	SyncBlock *SyncBlockResp
}

sync block response msg

type ViewChangeReq

type ViewChangeReq struct {
	Account   account.Account
	Nodes     []account.Account
	Timestamp int64
	ViewNum   uint64
}

type ViewChangeReqMessage

type ViewChangeReqMessage struct {
	ViewChange *ViewChangeReq
}

change view request msg

Jump to

Keyboard shortcuts

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