message

package
v0.0.0-...-538a9bf Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	GetVersion() (Message, error)

	Version(
		networkID,
		nodeID uint32,
		myTime uint64,
		ip utils.IPDesc,
		myVersion string,
		myVersionTime uint64,
		sig []byte,
	) (Message, error)

	GetPeerList() (Message, error)

	PeerList(
		peers []utils.IPCertDesc,
		includeIsCompressedFlag,
		compress bool,
	) (Message, error)

	Ping() (Message, error)

	Pong() (Message, error)

	GetAcceptedFrontier(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
	) (Message, error)

	AcceptedFrontier(
		chainID ids.ID,
		requestID uint32,
		containerIDs []ids.ID,
	) (Message, error)

	GetAccepted(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
		containerIDs []ids.ID,
	) (Message, error)

	Accepted(
		chainID ids.ID,
		requestID uint32,
		containerIDs []ids.ID,
	) (Message, error)

	GetAncestors(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
		containerID ids.ID,
	) (Message, error)

	MultiPut(
		chainID ids.ID,
		requestID uint32,
		containers [][]byte,
		includeIsCompressedFlag bool,
		compressed bool,
	) (Message, error)

	Get(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
		containerID ids.ID,
	) (Message, error)

	Put(
		chainID ids.ID,
		requestID uint32,
		containerID ids.ID,
		container []byte,
		includeIsCompressedFlag bool,
		compress bool,
	) (Message, error)

	PushQuery(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
		containerID ids.ID,
		container []byte,
		includeIsCompressedFlag bool,
		compress bool,
	) (Message, error)

	PullQuery(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
		containerID ids.ID,
	) (Message, error)

	Chits(
		chainID ids.ID,
		requestID uint32,
		containerIDs []ids.ID,
	) (Message, error)
}

func NewBuilder

func NewBuilder(c Codec) Builder

type Codec

type Codec interface {
	Pack(
		op Op,
		fieldValues map[Field]interface{},
		includeIsCompressedFlag bool,
		compress bool,
	) (Message, error)

	Parse(bytes []byte, parseIsCompressedFlag bool) (Message, error)
}

func NewCodec

func NewCodec(namespace string, metrics prometheus.Registerer) (Codec, error)

func NewCodecWithAllocator

func NewCodecWithAllocator(namespace string, metrics prometheus.Registerer, getBytes func() []byte) (Codec, error)

type Field

type Field uint32

Field that may be packed into a message

const (
	VersionStr          Field = iota // Used in handshake
	NetworkID                        // Used in handshake
	NodeID                           // Used in handshake
	MyTime                           // Used in handshake
	IP                               // Used in handshake
	Peers                            // Used in handshake
	ChainID                          // Used for dispatching
	RequestID                        // Used for all messages
	Deadline                         // Used for request messages
	ContainerID                      // Used for querying
	ContainerBytes                   // Used for gossiping
	ContainerIDs                     // Used for querying
	MultiContainerBytes              // Used in MultiPut
	SigBytes                         // Used in handshake / peer gossiping
	VersionTime                      // Used in handshake / peer gossiping
	SignedPeers                      // Used in peer gossiping
)

Fields that may be packed. These values are not sent over the wire.

func (Field) Packer

func (f Field) Packer() func(*wrappers.Packer, interface{})

Packer returns the packer function that can be used to pack this field.

func (Field) String

func (f Field) String() string

func (Field) Unpacker

func (f Field) Unpacker() func(*wrappers.Packer) interface{}

Unpacker returns the unpacker function that can be used to unpack this field.

type Message

type Message interface {
	Op() Op
	Get(Field) interface{}
	Bytes() []byte
}

Message represents a set of fields that can be serialized into a byte stream

type Op

type Op byte

Op is an opcode

const (
	// Handshake:
	GetVersion Op = iota

	GetPeerList

	Ping
	Pong
	// Bootstrapping:
	GetAcceptedFrontier
	AcceptedFrontier
	GetAccepted
	Accepted
	GetAncestors
	MultiPut
	// Consensus:
	Get
	Put
	PushQuery
	PullQuery
	Chits
	// Handshake / peer gossiping
	Version
	PeerList
)

Types of messages that may be sent between nodes Note: If you add a new Op below, you must also add it to ops (declared below)

func (Op) Compressable

func (op Op) Compressable() bool

func (Op) String

func (op Op) String() string

Jump to

Keyboard shortcuts

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