message

package
Version: v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 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)

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

	GetPeerList() (Message, error)

	PeerList(
		peers []utils.IPCertDesc,
		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,
		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,
		compress bool,
	) (Message, error)

	PushQuery(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
		containerID ids.ID,
		container []byte,
		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)

	AppRequest(
		chainID ids.ID,
		requestID uint32,
		deadline uint64,
		msg []byte,
		compress bool,
	) (Message, error)

	AppResponse(
		chainID ids.ID,
		requestID uint32,
		msg []byte,
		compress bool,
	) (Message, error)

	AppGossip(
		chainID ids.ID,
		msg []byte,
		compress bool,
	) (Message, error)
}

func NewBuilder

func NewBuilder(c Codec) Builder

type Codec

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

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

func NewCodec

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

func NewCodecWithAllocator

func NewCodecWithAllocator(namespace string, metrics prometheus.Registerer, getBytes func() []byte, maxMessageSize int64) (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
	TrackedSubnets                   // Used in handshake / peer gossiping
	AppRequestBytes                  // Used at application level
	AppResponseBytes                 // Used at application level
	AppGossipBytes                   // Used at application level
)

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
	BytesSavedCompression() int
}

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
	VersionWithSubnets
	// Application level:
	AppRequest
	AppResponse
	AppGossip
)

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL