codec

package
v0.33.18-rc Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterfaceFromMessageCode

func InterfaceFromMessageCode(code MessageCode) (interface{}, string, error)

InterfaceFromMessageCode returns an interface with the correct underlying go type of the message code represents. Expected error returns during normal operations:

  • ErrUnknownMsgCode if message code does not match any of the configured message codes above.

func IsErrInvalidEncoding added in v0.29.0

func IsErrInvalidEncoding(err error) bool

IsErrInvalidEncoding returns true if an error is ErrInvalidEncoding

func IsErrMsgUnmarshal added in v0.27.3

func IsErrMsgUnmarshal(err error) bool

IsErrMsgUnmarshal returns true if an error is ErrMsgUnmarshal

func IsErrUnknownMsgCode added in v0.27.3

func IsErrUnknownMsgCode(err error) bool

IsErrUnknownMsgCode returns true if an error is ErrUnknownMsgCode

Types

type ErrInvalidEncoding added in v0.29.0

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

ErrInvalidEncoding indicates that the message code byte (first byte of message payload) is unknown.

func NewInvalidEncodingErr added in v0.29.0

func NewInvalidEncodingErr(err error) ErrInvalidEncoding

NewInvalidEncodingErr returns a new ErrInvalidEncoding

func (ErrInvalidEncoding) Error added in v0.29.0

func (e ErrInvalidEncoding) Error() string

type ErrMsgUnmarshal added in v0.27.3

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

ErrMsgUnmarshal indicates that the message could not be unmarshalled.

func NewMsgUnmarshalErr added in v0.27.3

func NewMsgUnmarshalErr(code uint8, msgType string, err error) ErrMsgUnmarshal

NewMsgUnmarshalErr returns a new ErrMsgUnmarshal

func (ErrMsgUnmarshal) Error added in v0.27.3

func (e ErrMsgUnmarshal) Error() string

type ErrUnknownMsgCode added in v0.27.3

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

ErrUnknownMsgCode indicates that the message code byte (first byte of message payload) is unknown.

func NewUnknownMsgCodeErr added in v0.27.3

func NewUnknownMsgCodeErr(code MessageCode) ErrUnknownMsgCode

NewUnknownMsgCodeErr returns a new ErrUnknownMsgCode

func (ErrUnknownMsgCode) Error added in v0.27.3

func (e ErrUnknownMsgCode) Error() string

type MessageCode added in v0.30.0

type MessageCode uint8
const (
	CodeMin MessageCode = iota + 1

	// consensus
	CodeBlockProposal
	CodeBlockVote
	CodeTimeoutObject

	// protocol state sync
	CodeSyncRequest
	CodeSyncResponse
	CodeRangeRequest
	CodeBatchRequest
	CodeBlockResponse

	// cluster consensus
	CodeClusterBlockProposal
	CodeClusterBlockVote
	CodeClusterBlockResponse
	CodeClusterTimeoutObject

	// collections, guarantees & transactions
	CodeCollectionGuarantee
	CodeTransaction
	CodeTransactionBody

	// core messages for execution & verification
	CodeExecutionReceipt
	CodeResultApproval

	// data exchange for execution of blocks
	CodeChunkDataRequest
	CodeChunkDataResponse

	// result approvals
	CodeApprovalRequest
	CodeApprovalResponse

	// generic entity exchange engines
	CodeEntityRequest
	CodeEntityResponse

	// testing
	CodeEcho

	// DKG
	CodeDKGMessage

	CodeMax
)

func MessageCodeFromInterface

func MessageCodeFromInterface(v interface{}) (MessageCode, string, error)

MessageCodeFromInterface returns the correct Code based on the underlying type of message v.

func MessageCodeFromPayload added in v0.30.0

func MessageCodeFromPayload(payload []byte) (MessageCode, error)

MessageCodeFromPayload checks the length of the payload bytes before returning the first byte encoded MessageCode. Expected error returns during normal operations:

  • ErrInvalidEncoding if payload is empty

func (MessageCode) Uint8 added in v0.30.0

func (m MessageCode) Uint8() uint8

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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