Help us shape the future of Go! Take the 2026 Go Developer Survey

block

package
v1.36.183 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package block is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block interface {
	ID() ids.ID
	Parent() ids.ID
	Height() uint64
	// Timestamp that this block was created at
	Timestamp() time.Time
	MerkleRoot() ids.ID
	Bytes() []byte

	// Txs returns the transactions contained in the block
	Txs() []*txs.Tx
}

Block defines the common stateless interface for all blocks. There is no codec: a block is a self-describing native-ZAP buffer whose bytes are authoritative (ID = hash(bytes)); see Parser.ParseBlock.

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) 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) MerkleRoot

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

MerkleRoot mocks base method.

func (*MockBlock) Parent

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

Parent mocks base method.

func (*MockBlock) Timestamp

func (m *MockBlock) Timestamp() time.Time

Timestamp mocks base method.

func (*MockBlock) Txs

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

Txs 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) 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) MerkleRoot

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

MerkleRoot indicates an expected call of MerkleRoot.

func (*MockBlockMockRecorder) Parent

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

Parent indicates an expected call of Parent.

func (*MockBlockMockRecorder) Timestamp

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

Timestamp indicates an expected call of Timestamp.

func (*MockBlockMockRecorder) Txs

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

Txs indicates an expected call of Txs.

type Parser

type Parser interface {
	txs.Parser

	ParseBlock(bytes []byte) (Block, error)
	ParseGenesisBlock(bytes []byte) (Block, error)
}

Parser parses both X-chain txs and blocks. It embeds the codec-free txs.Parser (for ParseTx / ParseGenesisTx) and adds native-ZAP block parsing.

func NewCustomParser

func NewCustomParser(
	fxIndex *txs.FxIndex,
	clock *mockable.Clock,
	log log.Logger,
	fxs []fxs.Fx,
) (Parser, error)

func NewParser

func NewParser(fxs []fxs.Fx) (Parser, error)

type StandardBlock

type StandardBlock struct {
	// parent's ID
	PrntID ids.ID `json:"parentID"`
	// This block's height. The genesis block is at height 0.
	Hght uint64 `json:"height"`
	Time uint64 `json:"time"`
	Root ids.ID `json:"merkleRoot"`
	// List of transactions contained in this block.
	Transactions []*txs.Tx `json:"txs"`

	BlockID ids.ID `json:"id"`
	// contains filtered or unexported fields
}

StandardBlock is the X-chain block. The struct is the source of truth; bytes is the cached native-ZAP wire encoding. Txs are self-describing via their own tx.Bytes(), so a block stores the per-tx byte lengths as a u32 list plus the concatenated tx bytes, and Parse re-splits them through txs.Parse (zero copy).

Object fixed section (all offsets object-relative):

ParentID  32B @ 0
Height    u64 @ 32
Time      u64 @ 40
Root      32B @ 48   (merkle execution root; ids.Empty pre-activation)
TxLengths 8B  @ 80   (u32 list ptr — one entry per tx)
TxBlob    8B  @ 88   (bytes ptr — concat of each tx.Bytes())

func NewStandardBlock

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

func NewStandardBlockWithRoot added in v1.30.10

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

NewStandardBlockWithRoot builds a StandardBlock carrying an explicit merkle root and serializes it. NewStandardBlock is the root == ids.Empty special case — the historical, pre-activation shape. Above the xvm execution_root activation height the builder passes the computed execution_root here so it is part of the serialized, hashed block bytes.

func (*StandardBlock) Bytes

func (b *StandardBlock) Bytes() []byte

func (*StandardBlock) Height

func (b *StandardBlock) Height() uint64

func (*StandardBlock) ID

func (b *StandardBlock) ID() ids.ID

func (*StandardBlock) MerkleRoot

func (b *StandardBlock) MerkleRoot() ids.ID

func (*StandardBlock) Parent

func (b *StandardBlock) Parent() ids.ID

func (*StandardBlock) Timestamp

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

func (*StandardBlock) Txs

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

Directories

Path Synopsis
Package executor is a generated GoMock package.
Package executor is a generated GoMock package.
executormock
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