handler

package
v1.13.4-lux.18-chain Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: BSD-3-Clause Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConnectedEnoughStake = errors.New("not connected to enough stake")

Functions

This section is empty.

Types

type Engine

type Engine struct {
	StateSyncer  core.StateSyncer
	Bootstrapper core.BootstrapableEngine
	Consensus    core.Engine
}

Engine is a wrapper around a consensus engine's components.

func (*Engine) Get

func (e *Engine) Get(state snow.State) (core.Engine, bool)

Get returns the engine corresponding to the provided state, and whether its corresponding engine is initialized (not nil).

type EngineManager

type EngineManager struct {
	Avalanche *Engine
	Chain     *Engine
}

EngineManager resolves the engine that should be used given the current execution context of the chain.

func (*EngineManager) Get

func (e *EngineManager) Get(engineType p2p.EngineType) *Engine

Get returns the engine corresponding to the provided type if possible. If an engine type is not specified, the initial engine type is returned.

type Handler

type Handler interface {
	health.Checker

	Context() *snow.ConsensusContext
	// ShouldHandle returns true if the node with the given ID is allowed to send
	// messages to this chain. If the node is not allowed to send messages to
	// this chain, the message should be dropped.
	ShouldHandle(nodeID ids.NodeID) bool

	SetEngineManager(engineManager *EngineManager)
	GetEngineManager() *EngineManager

	SetOnStopped(onStopped func())
	Start(ctx context.Context, recoverPanic bool)
	Push(ctx context.Context, msg Message)
	Len() int

	Stop(ctx context.Context)
	StopWithError(ctx context.Context, err error)
	// AwaitStopped returns an error if the call would block and [ctx] is done.
	// Even if [ctx] is done when passed into this function, this function will
	// return a nil error if it will not block.
	AwaitStopped(ctx context.Context) (time.Duration, error)
}

func New

func New(
	ctx *snow.ConsensusContext,
	cn *block.ChangeNotifier,
	subscription core.Subscription,
	validators validators.Manager,
	gossipFrequency time.Duration,
	threadPoolSize int,
	resourceTracker tracker.ResourceTracker,
	subnet subnets.Subnet,
	peerTracker commontracker.Peers,
	p2pTracker *p2p.PeerTracker,
	reg prometheus.Registerer,
	haltBootstrapping func(),
) (Handler, error)

Initialize this consensus handler [engine] must be initialized before initializing this handler

type Message

type Message struct {
	// The original message from the peer
	message.InboundMessage
	// The desired engine type to execute this message. If not specified,
	// the current executing engine type is used.
	EngineType p2p.EngineType
}

Message defines individual messages that have been parsed from the network and are now pending execution from the chain.

type MessageQueue

type MessageQueue interface {
	// Add a message.
	//
	// If called after [Shutdown], the message will immediately be marked as
	// having been handled.
	Push(context.Context, Message)

	// Remove and return a message and its context.
	//
	// If there are no available messages, this function will block until a
	// message becomes available or the queue is [Shutdown].
	Pop() (context.Context, Message, bool)

	// Returns the number of messages currently on the queue
	Len() int

	// Shutdown and empty the queue.
	Shutdown()
}

func NewMessageQueue

func NewMessageQueue(
	log logging.Logger,
	subnetID ids.ID,
	vdrs validators.Manager,
	cpuTracker tracker.Tracker,
	metricsNamespace string,
	reg prometheus.Registerer,
) (MessageQueue, error)

Directories

Path Synopsis
Package handlermock is a generated GoMock package.
Package handlermock is a generated GoMock package.

Jump to

Keyboard shortcuts

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