messages

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	RequestMessageType       // 1, request message for bft
	ProposalMessageType      // 2, proposal message for bft
	ResponseMessageType      // 3, response message for bft
	CommitMessageType        // 4, commit message for bft
	SyncBlockReqMessageType  // 5, sync block request
	SyncBlockRespMessageType // 6, sync block response
	ViewChangeMessageReqType // 7, change view request
	OnlineRequestType        // 8, node online request
	OnlineResponseType       // 9, response for node online request
)

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 OnlineRequest added in v0.3.0

type OnlineRequest struct {
	Account     account.Account
	Timestamp   int64
	BlockHeight uint64
}

type OnlineRequestMessage added in v0.3.0

type OnlineRequestMessage struct {
	OnlineRequest *OnlineRequest
}

online request

type OnlineResponse added in v0.3.0

type OnlineResponse struct {
	Account     account.Account
	Timestamp   int64
	BlockHeight uint64
	ViewNum     uint64
	Nodes       []account.Account
	Master      account.Account
}

type OnlineResponseMessage added in v0.3.0

type OnlineResponseMessage struct {
	OnlineResponse *OnlineResponse
}

online response

type Proposal

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

type ProposalMessage

type ProposalMessage struct {
	Proposal *Proposal
}

proposal msg

type Request

type Request struct {
	Timestamp int64
	Account   account.Account
	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
	BlockHeight uint64
}

type ResponseMessage

type ResponseMessage struct {
	Response *Response
}

response msg

type SyncBlockReq

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

type SyncBlockReqMessage

type SyncBlockReqMessage struct {
	SyncBlockReq *SyncBlockReq
}

sync block request msg

type SyncBlockResp

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

type SyncBlockRespMessage

type SyncBlockRespMessage struct {
	SyncBlockResp *SyncBlockResp
}

sync block response msg

type SyncRoleAssignmentReq added in v0.3.0

type SyncRoleAssignmentReq struct {
	Account   account.Account
	Timestamp int64
	ViewNum   uint64
}

type SyncRoleAssignmentReqMessage added in v0.3.0

type SyncRoleAssignmentReqMessage struct {
	SyncRoleAssignmentReq *SyncRoleAssignmentReq
}

sync role assignment from other node

type SyncRoleAssignmentResp added in v0.3.0

type SyncRoleAssignmentResp struct {
	Account   account.Account
	ViewNum   uint64
	Master    account.Account
	Timestamp int64
}

type SyncRoleAssignmentRespMessage added in v0.3.0

type SyncRoleAssignmentRespMessage struct {
	SyncRoleAssignmentResp *SyncRoleAssignmentResp
}

send sync role assignment to other node

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