network

package
v0.8.23 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: GPL-3.0, LGPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPeers is returned when there are no peers to send a request to
	ErrNoPeers = errors.New("no peers available")

	// ErrNoSender is returned when no sender is configured
	ErrNoSender = errors.New("no sender configured")

	// ErrNetworkClosed is returned when the network has been shut down
	ErrNetworkClosed = errors.New("network closed")

	// ErrRequestCancelled is returned when a request is cancelled
	ErrRequestCancelled = errors.New("request cancelled")

	// ErrRequestTimeout is returned when a request times out
	ErrRequestTimeout = errors.New("request timeout")
)

Functions

This section is empty.

Types

type Network

type Network struct {
	*p2p.Network
	// contains filtered or unexported fields
}

Network handles peer-to-peer networking for the EVM It embeds p2p.Network to provide the base functionality

func NewNetwork

func NewNetwork(
	ctx context.Context,
	sender p2p.Sender,
	codec codec.Manager,
	maxOutboundActiveRequests int64,
	metrics metric.Registerer,
) (*Network, error)

NewNetwork creates a new Network instance

func (*Network) AppResponse added in v0.8.11

func (n *Network) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

AppResponse handles an incoming response

func (*Network) Gossip added in v0.8.11

func (n *Network) Gossip(msg []byte) error

Gossip broadcasts a message to all peers

func (*Network) P2PValidators

func (n *Network) P2PValidators() *p2p.Validators

P2PValidators returns the p2p validators if available

func (*Network) SendSyncedAppRequest added in v0.8.11

func (n *Network) SendSyncedAppRequest(ctx context.Context, nodeID ids.NodeID, request []byte) ([]byte, error)

SendSyncedAppRequest sends a request to a specific peer

func (*Network) SendSyncedAppRequestAny added in v0.8.11

func (n *Network) SendSyncedAppRequestAny(ctx context.Context, minVersion *version.Application, request []byte) ([]byte, ids.NodeID, error)

SendSyncedAppRequestAny sends a request to any available peer

func (*Network) SetRequestHandler

func (n *Network) SetRequestHandler(handler interface{})

SetRequestHandler sets the handler for incoming requests Accepts any type to avoid import cycles with plugin/evm/message

func (*Network) Shutdown

func (n *Network) Shutdown()

Shutdown stops the network

func (*Network) Size

func (n *Network) Size() int

Size returns the number of connected peers

func (*Network) TrackBandwidth added in v0.8.11

func (n *Network) TrackBandwidth(nodeID ids.NodeID, bandwidth float64)

TrackBandwidth records bandwidth usage for a peer

type SyncedNetworkClient

type SyncedNetworkClient interface {
	SendSyncedAppRequestAny(ctx context.Context, minVersion *version.Application, request []byte) ([]byte, ids.NodeID, error)
	SendSyncedAppRequest(ctx context.Context, nodeID ids.NodeID, request []byte) ([]byte, error)
	Gossip(msg []byte) error
	TrackBandwidth(nodeID ids.NodeID, bandwidth float64)
}

SyncedNetworkClient is the interface required by the state sync client

Jump to

Keyboard shortcuts

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