block

package
v1.36.135 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: BSD-3-Clause Imports: 10 Imported by: 8

Documentation

Overview

Package block is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrExtraSpace = errors.New("block: trailing bytes after zap message")

ErrExtraSpace is returned when a block buffer carries bytes beyond the self-delimiting zap message — a malleability vector (ID = hash(bytes) would change while the wrapped message is identical). Blocks MUST be canonical.

Functions

This section is empty.

Types

type AbortBlock added in v1.26.35

type AbortBlock struct {
	// contains filtered or unexported fields
}

AbortBlock is the canonical P-Chain abort outcome of a ProposalBlock. It carries a timestamp and no txs; the struct is the zap buffer.

func NewAbortBlock added in v1.26.35

func NewAbortBlock(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
) (*AbortBlock, error)

func (AbortBlock) Bytes added in v1.36.3

func (b AbortBlock) Bytes() []byte

func (*AbortBlock) DecisionTxs added in v1.36.117

func (*AbortBlock) DecisionTxs() []*txs.Tx

func (AbortBlock) Height added in v1.36.3

func (b AbortBlock) Height() uint64

func (AbortBlock) ID added in v1.36.3

func (b AbortBlock) ID() ids.ID

func (AbortBlock) InitRuntime added in v1.26.35

func (b AbortBlock) InitRuntime(rt *runtime.Runtime)

InitRuntime binds the runtime into every embedded tx. It dispatches on the wire kind so the base — which owns the layout knowledge — is the one place that knows where a block's txs live, without depending on the concrete type's accessors (Go embedding has no virtual dispatch).

func (AbortBlock) Parent added in v1.36.3

func (b AbortBlock) Parent() ids.ID

func (AbortBlock) Timestamp added in v1.26.35

func (b AbortBlock) Timestamp() time.Time

func (*AbortBlock) Visit added in v1.26.35

func (b *AbortBlock) Visit(v Visitor) error

type Block

type Block interface {
	RuntimeInitializable
	ID() ids.ID
	Parent() ids.ID
	Bytes() []byte
	Height() uint64

	// DecisionTxs returns the transactions this block charges for: the ones
	// submitted to this chain by someone else, paid for by whoever submitted
	// them, and priceable by both fee calculators.
	//
	// A transaction the chain emits about itself is never among them. A
	// proposal block's own tx is reachable only as (*ProposalBlock).Tx() —
	// typed and singular, so it cannot be handed to anything that takes a
	// list of transactions to price, re-issue, or otherwise treat as an
	// assertion someone else made.
	DecisionTxs() []*txs.Tx

	// Visit calls [visitor] with this block's concrete type.
	Visit(visitor Visitor) error
}

Block is the common stateless interface for all P-chain blocks. Every block is a single native-ZAP object; there is no codec and no initialize step — the bytes are authoritative and blocks are built by New*Block or read by Parse, both of which bind ID = hash(bytes).

func Parse

func Parse(b []byte) (Block, error)

Parse decodes a native-ZAP P-chain block. It reads the blockKind discriminator and wraps the matching typed block over b (byte-preserving).

type CommitBlock added in v1.26.35

type CommitBlock struct {
	// contains filtered or unexported fields
}

CommitBlock is the canonical P-Chain commit outcome of a ProposalBlock. It carries a timestamp and no txs; the struct is the zap buffer.

func NewCommitBlock added in v1.26.35

func NewCommitBlock(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
) (*CommitBlock, error)

func (CommitBlock) Bytes added in v1.36.3

func (b CommitBlock) Bytes() []byte

func (*CommitBlock) DecisionTxs added in v1.36.117

func (*CommitBlock) DecisionTxs() []*txs.Tx

func (CommitBlock) Height added in v1.36.3

func (b CommitBlock) Height() uint64

func (CommitBlock) ID added in v1.36.3

func (b CommitBlock) ID() ids.ID

func (CommitBlock) InitRuntime added in v1.26.35

func (b CommitBlock) InitRuntime(rt *runtime.Runtime)

InitRuntime binds the runtime into every embedded tx. It dispatches on the wire kind so the base — which owns the layout knowledge — is the one place that knows where a block's txs live, without depending on the concrete type's accessors (Go embedding has no virtual dispatch).

func (CommitBlock) Parent added in v1.36.3

func (b CommitBlock) Parent() ids.ID

func (CommitBlock) Timestamp added in v1.26.35

func (b CommitBlock) Timestamp() time.Time

func (*CommitBlock) Visit added in v1.26.35

func (b *CommitBlock) Visit(v Visitor) error

type MockBlock

type MockBlock struct {
	// contains filtered or unexported fields
}

MockBlock is a mock of Block interface.

func NewMockBlock

func NewMockBlock(ctrl *gomock.Controller) *MockBlock

NewMockBlock creates a new mock instance.

func (*MockBlock) Bytes

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

Bytes mocks base method.

func (*MockBlock) DecisionTxs added in v1.36.117

func (m *MockBlock) DecisionTxs() []*txs.Tx

DecisionTxs mocks base method.

func (*MockBlock) EXPECT

func (m *MockBlock) EXPECT() *MockBlockMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBlock) Height

func (m *MockBlock) Height() uint64

Height mocks base method.

func (*MockBlock) ID

func (m *MockBlock) ID() ids.ID

ID mocks base method.

func (*MockBlock) InitRuntime added in v1.22.87

func (m *MockBlock) InitRuntime(rt *runtime.Runtime)

InitRuntime mocks base method.

func (*MockBlock) Parent

func (m *MockBlock) Parent() ids.ID

Parent mocks base method.

func (*MockBlock) Visit

func (m *MockBlock) Visit(visitor Visitor) error

Visit mocks base method.

type MockBlockMockRecorder

type MockBlockMockRecorder struct {
	// contains filtered or unexported fields
}

MockBlockMockRecorder is the mock recorder for MockBlock.

func (*MockBlockMockRecorder) Bytes

func (mr *MockBlockMockRecorder) Bytes() *gomock.Call

Bytes indicates an expected call of Bytes.

func (*MockBlockMockRecorder) DecisionTxs added in v1.36.117

func (mr *MockBlockMockRecorder) DecisionTxs() *gomock.Call

DecisionTxs indicates an expected call of DecisionTxs.

func (*MockBlockMockRecorder) Height

func (mr *MockBlockMockRecorder) Height() *gomock.Call

Height indicates an expected call of Height.

func (*MockBlockMockRecorder) ID

func (mr *MockBlockMockRecorder) ID() *gomock.Call

ID indicates an expected call of ID.

func (*MockBlockMockRecorder) InitRuntime added in v1.22.87

func (mr *MockBlockMockRecorder) InitRuntime(rt any) *gomock.Call

InitRuntime indicates an expected call of InitRuntime.

func (*MockBlockMockRecorder) Parent

func (mr *MockBlockMockRecorder) Parent() *gomock.Call

Parent indicates an expected call of Parent.

func (*MockBlockMockRecorder) Visit

func (mr *MockBlockMockRecorder) Visit(visitor any) *gomock.Call

Visit indicates an expected call of Visit.

type ProposalBlock added in v1.26.35

type ProposalBlock struct {
	// contains filtered or unexported fields
}

ProposalBlock is the canonical P-Chain proposal block. It carries a per-block timestamp, a tail of decision txs (stored as the u32 length list + blob), and a single proposal Tx that commits atomically with them.

func NewProposalBlock added in v1.26.35

func NewProposalBlock(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
	proposalTx *txs.Tx,
	decisionTxs []*txs.Tx,
) (*ProposalBlock, error)

func (ProposalBlock) Bytes added in v1.36.3

func (b ProposalBlock) Bytes() []byte

func (*ProposalBlock) DecisionTxs added in v1.36.113

func (b *ProposalBlock) DecisionTxs() []*txs.Tx

DecisionTxs returns the decision txs in wire order. The proposal tx is not among them; it runs on its own path, unpriced, and is reached through Tx.

func (ProposalBlock) Height added in v1.36.3

func (b ProposalBlock) Height() uint64

func (ProposalBlock) ID added in v1.36.3

func (b ProposalBlock) ID() ids.ID

func (ProposalBlock) InitRuntime added in v1.26.35

func (b ProposalBlock) InitRuntime(rt *runtime.Runtime)

InitRuntime binds the runtime into every embedded tx. It dispatches on the wire kind so the base — which owns the layout knowledge — is the one place that knows where a block's txs live, without depending on the concrete type's accessors (Go embedding has no virtual dispatch).

func (ProposalBlock) Parent added in v1.36.3

func (b ProposalBlock) Parent() ids.ID

func (ProposalBlock) Timestamp added in v1.26.35

func (b ProposalBlock) Timestamp() time.Time

func (*ProposalBlock) Tx added in v1.26.35

func (b *ProposalBlock) Tx() *txs.Tx

Tx returns the proposal tx. Never nil: a block is only made with a proposal slot that carries bytes, and only parsed if that slot reads back. Singular by type, so it cannot join a list on its way to a fee calculator or a mempool.

func (*ProposalBlock) Visit added in v1.26.35

func (b *ProposalBlock) Visit(v Visitor) error

type RuntimeInitializable added in v1.22.87

type RuntimeInitializable interface {
	InitRuntime(rt *runtime.Runtime)
}

RuntimeInitializable binds a runtime into a block's embedded txs.

type StandardBlock added in v1.26.35

type StandardBlock struct {
	// contains filtered or unexported fields
}

StandardBlock is the canonical P-Chain standard block. It carries a per-block timestamp and an ordered list of decision txs, stored as a u32 length list + concatenated tx blob in the zap buffer.

func NewStandardBlock added in v1.26.35

func NewStandardBlock(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
	txs []*txs.Tx,
) (*StandardBlock, error)

func (StandardBlock) Bytes added in v1.36.3

func (b StandardBlock) Bytes() []byte

func (*StandardBlock) DecisionTxs added in v1.36.117

func (b *StandardBlock) DecisionTxs() []*txs.Tx

DecisionTxs returns the decision txs in wire order. A standard block carries nothing else.

func (StandardBlock) Height added in v1.36.3

func (b StandardBlock) Height() uint64

func (StandardBlock) ID added in v1.36.3

func (b StandardBlock) ID() ids.ID

func (StandardBlock) InitRuntime added in v1.26.35

func (b StandardBlock) InitRuntime(rt *runtime.Runtime)

InitRuntime binds the runtime into every embedded tx. It dispatches on the wire kind so the base — which owns the layout knowledge — is the one place that knows where a block's txs live, without depending on the concrete type's accessors (Go embedding has no virtual dispatch).

func (StandardBlock) Parent added in v1.36.3

func (b StandardBlock) Parent() ids.ID

func (StandardBlock) Timestamp added in v1.26.35

func (b StandardBlock) Timestamp() time.Time

func (*StandardBlock) Visit added in v1.26.35

func (b *StandardBlock) Visit(v Visitor) error

type TimestampedBlock added in v1.26.35

type TimestampedBlock interface {
	Block
	Timestamp() time.Time
}

TimestampedBlock is a Block that carries a per-block timestamp. Every canonical P-chain block kind is timestamped.

type Visitor

type Visitor interface {
	AbortBlock(*AbortBlock) error
	CommitBlock(*CommitBlock) error
	ProposalBlock(*ProposalBlock) error
	StandardBlock(*StandardBlock) error
}

Visitor dispatches by the canonical P-Chain block type. Under carries a timestamp and is one of the four canonical kinds.

Directories

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

Jump to

Keyboard shortcuts

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