extension

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: GPL-3.0, LGPL-3.0 Imports: 19 Imported by: ? 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

This section is empty.

Functions

This section is empty.

Types

type BlockExtender

type BlockExtender interface {
	// NewBlockExtension is called when a new block is created
	NewBlockExtension(b ExtendedBlock) (BlockExtension, error)
}

type BlockExtension

type BlockExtension interface {
	// SyntacticVerify verifies the block syntactically
	// it can be implemented to extend inner block verification
	SyntacticVerify(rules extras.Rules) error
	// SemanticVerify verifies the block semantically
	// it can be implemented to extend inner block verification
	SemanticVerify() error
	// CleanupVerified is called when a block has passed SemanticVerify and SynctacticVerify,
	// and should be cleaned up due to error or verification runs under non-write mode. This
	// does not return an error because the block has already been verified.
	CleanupVerified()
	// Accept is called when a block is accepted by the block manager. Accept takes a
	// database.Batch that contains the changes that were made to the database as a result
	// of accepting the block. The changes in the batch should be flushed to the database in this method.
	Accept(acceptedBatch database.Batch) error
	// Reject is called when a block is rejected by the block manager
	Reject() error
}

BlockExtension allows the VM extension to handle block processing events.

type Config

type Config struct {
	// ConsensusCallbacks is the consensus callbacks to use
	// for the VM to be used in consensus engine.
	// Callback functions can be nil.
	ConsensusCallbacks dummy.ConsensusCallbacks
	// SyncSummaryProvider is the sync summary provider to use
	// for the VM to be used in syncer.
	// It's required and should be non-nil
	SyncSummaryProvider sync.SummaryProvider
	// SyncExtender can extend the syncer to handle custom sync logic.
	// It's optional and can be nil
	SyncExtender sync.Extender
	// SyncableParser is to parse summary messages from the network.
	// It's required and should be non-nil
	SyncableParser message.SyncableParser
	// BlockExtender allows the VM extension to create an extension to handle block processing events.
	// It's optional and can be nil
	BlockExtender BlockExtender
	// ExtraSyncLeafHandlerConfig is the extra configuration to handle leaf requests
	// in the network and syncer. It's optional and can be nil
	ExtraSyncLeafHandlerConfig *LeafRequestConfig
	// Clock is the clock to use for time related operations.
	// It's optional and can be nil
	Clock *mockable.Clock
}

Config is the configuration for the VM extension

func (*Config) Validate

func (c *Config) Validate() error

type ExtendedBlock

type ExtendedBlock interface {
	snowman.Block
	GetEthBlock() *types.Block
	GetBlockExtension() BlockExtension
}

ExtendedBlock is a block that can be used by the extension

type ExtensibleVM

type ExtensibleVM interface {
	// SetExtensionConfig sets the configuration for the VM extension
	// Should be called before any other method and only once
	SetExtensionConfig(config *Config) error

	// SetLastAcceptedBlock sets the last accepted block
	SetLastAcceptedBlock(lastAcceptedBlock snowman.Block) error
	// GetExtendedBlock returns the VMBlock for the given ID or an error if the block is not found
	GetExtendedBlock(context.Context, ids.ID) (ExtendedBlock, error)
	// LastAcceptedExtendedBlock returns the last accepted VM block
	LastAcceptedExtendedBlock() ExtendedBlock
	// IsBootstrapped returns true if the VM is bootstrapped
	IsBootstrapped() bool
	// ChainConfig returns the chain config for the VM
	ChainConfig() *params.ChainConfig
	// Ethereum returns the Ethereum client
	Ethereum() *eth.Ethereum
	// Config returns the configuration for the VM
	Config() config.Config
	// ReadLastAccepted returns the last accepted block hash and height
	ReadLastAccepted() (common.Hash, uint64, error)
	// VersionDB returns the versioned database for the VM
	VersionDB() *versiondb.Database
}

type InnerVM

InnerVM is the interface that must be implemented by the VM that's being wrapped by the extension

type LeafRequestConfig

type LeafRequestConfig struct {
	// LeafType is the type of the leaf node
	LeafType message.NodeType
	// MetricName is the name of the metric to use for the leaf request
	MetricName string
	// Handler is the handler to use for the leaf request
	Handler handlers.LeafRequestHandler
}

Jump to

Keyboard shortcuts

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