message

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: LGPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// EthMsgSoftCapSize is the ideal size of encoded transaction bytes we send in
	// any [EthTxs] or [AtomicTx] message. We do not limit inbound messages to
	// this size, however. Max inbound message size is enforced by the codec
	// (512KB).
	EthMsgSoftCapSize = common.StorageSize(64 * units.KiB)
)
View Source
const Version = uint16(0)

Variables

This section is empty.

Functions

func BuildCodec

func BuildCodec() (codec.Manager, error)

func BuildMessage

func BuildMessage(codec codec.Manager, msg Message) ([]byte, error)

func RequestToBytes

func RequestToBytes(codec codec.Manager, request Request) ([]byte, error)

RequestToBytes marshals the given request object into bytes

Types

type AtomicTx

type AtomicTx struct {
	Tx []byte `serialize:"true"`
	// contains filtered or unexported fields
}

func (*AtomicTx) Bytes

func (m *AtomicTx) Bytes() []byte

func (*AtomicTx) Handle

func (msg *AtomicTx) Handle(handler GossipHandler, nodeID ids.ShortID) error

func (*AtomicTx) Type

func (msg *AtomicTx) Type() string

type EthTxs

type EthTxs struct {
	Txs []byte `serialize:"true"`
	// contains filtered or unexported fields
}

func (*EthTxs) Bytes

func (m *EthTxs) Bytes() []byte

func (*EthTxs) Handle

func (msg *EthTxs) Handle(handler GossipHandler, nodeID ids.ShortID) error

func (*EthTxs) Type

func (msg *EthTxs) Type() string

type GossipHandler

type GossipHandler interface {
	HandleAtomicTx(nodeID ids.ShortID, msg *AtomicTx) error
	HandleEthTxs(nodeID ids.ShortID, msg *EthTxs) error
}

GossipHandler handles incoming gossip messages

type Message

type Message interface {
	// Handle this message with the correct message handler
	Handle(handler GossipHandler, nodeID ids.ShortID) error

	// Bytes returns the binary representation of this message
	//
	// Bytes should only be called after being initialized
	Bytes() []byte

	// Type returns user-friendly name for this object that can be used for logging
	Type() string
	// contains filtered or unexported methods
}

func ParseMessage

func ParseMessage(codec codec.Manager, bytes []byte) (Message, error)

type NoopMempoolGossipHandler

type NoopMempoolGossipHandler struct{}

func (NoopMempoolGossipHandler) HandleAtomicTx

func (NoopMempoolGossipHandler) HandleAtomicTx(nodeID ids.ShortID, _ *AtomicTx) error

func (NoopMempoolGossipHandler) HandleEthTxs

func (NoopMempoolGossipHandler) HandleEthTxs(nodeID ids.ShortID, _ *EthTxs) error

type Request

type Request interface {
	// Handle allows `Request` to call respective methods on handler to handle
	// this particular request type
	Handle(ctx context.Context, nodeID ids.ShortID, requestID uint32, handler RequestHandler) ([]byte, error)

	// Type returns user-friendly name for this object that can be used for logging
	Type() string
}

Request represents a Network request type

func BytesToRequest

func BytesToRequest(codec codec.Manager, requestBytes []byte) (Request, error)

BytesToRequest unmarshals the given requestBytes into Request object

type RequestHandler

type RequestHandler interface{}

RequestHandler interface handles incoming requests from peers Must have methods in format of handleType(context.Context, ids.ShortID, uint32, request Type) error so that the Request object of relevant Type can invoke its respective handle method on this struct. Also see GossipHandler for implementation style.

type ResponseHandler

type ResponseHandler interface {
	// OnResponse is invoked when the peer responded to a request
	OnResponse(nodeID ids.ShortID, requestID uint32, response []byte) error
	// OnFailure is invoked when there was a failure in processing a request
	// The FailureReason outlines the underlying cause.
	OnFailure(nodeID ids.ShortID, requestID uint32) error
}

ResponseHandler handles response for a sent request Only one of OnResponse or OnFailure is called for a given requestID, not both

Jump to

Keyboard shortcuts

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