executor

package
v1.11.11-rc.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: BSD-3-Clause Imports: 26 Imported by: 2

README

Package executor

This package deals with state management for P-Chain blocks.

*Block

The *Block type implements the snowman.Block interface. This is the type that the platformvm deals with when it uses snowman.Blocks. *Block wraps a blocks.Block and a manager. The *Block itself doesn't have any state. The state is all held by the manager, and the *Block acts upon the manager to get/set the state. Therefore, we don't need to worry about deduplicating *Block instances.

The platformvm uses the manager to create blocks and query block state because the manager.GetBlock returns a stateful block (*Block), whereas state.State's GetStatelessBlock returns a blocks.Block.

Visitors

This package contains three implementations of blocks.Visitor: verifier, acceptor and rejector. These implement the logic for verifying, accepting and rejecting blocks. Each implementation has a reference to a shared *backend, which maintains state, etc. (The manager has a reference to the shared *backend as well.)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChainNotSynced = errors.New("chain not synced")
)
View Source
var (
	ErrConflictingBlockTxs = errors.New("block contains conflicting transactions")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	block.Block
	// contains filtered or unexported fields
}

Exported for testing in platformvm package.

func (*Block) Accept

func (b *Block) Accept(context.Context) error

func (*Block) Options

func (b *Block) Options(context.Context) ([2]snowman.Block, error)

func (*Block) Reject

func (b *Block) Reject(context.Context) error

func (*Block) ShouldVerifyWithContext added in v1.11.11

func (*Block) ShouldVerifyWithContext(context.Context) (bool, error)

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

func (*Block) Verify

func (b *Block) Verify(ctx context.Context) error

func (*Block) VerifyWithContext added in v1.11.11

func (b *Block) VerifyWithContext(_ context.Context, ctx *smblock.Context) error

type Manager

type Manager interface {
	state.Versions

	// Returns the ID of the most recently accepted block.
	LastAccepted() ids.ID

	SetPreference(blkID ids.ID) (updated bool)
	Preferred() ids.ID

	GetBlock(blkID ids.ID) (snowman.Block, error)
	GetStatelessBlock(blkID ids.ID) (block.Block, error)
	NewBlock(block.Block) snowman.Block

	// VerifyTx verifies that the transaction can be issued based on the currently
	// preferred state. This should *not* be used to verify transactions in a block.
	VerifyTx(tx *txs.Tx) error

	// VerifyUniqueInputs verifies that the inputs are not duplicated in the
	// provided blk or any of its ancestors pinned in memory.
	VerifyUniqueInputs(blkID ids.ID, inputs set.Set[ids.ID]) error
}

func NewManager

func NewManager(
	mempool mempool.Mempool,
	metrics metrics.Metrics,
	s state.State,
	txExecutorBackend *executor.Backend,
	validatorManager validators.Manager,
) Manager

Directories

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

Jump to

Keyboard shortcuts

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