block

package
v1.10.17-rc.11 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: BSD-3-Clause Imports: 13 Imported by: 12

Documentation

Overview

Package block is a generated GoMock package.

Index

Constants

View Source
const Version = txs.Version

Version is the current default codec version

Variables

View Source
var (
	Codec        codec.Manager
	GenesisCodec codec.Manager
)

GenesisCode allows blocks of larger than usual size to be parsed. While this gives flexibility in accommodating large genesis blocks it must not be used to parse new, unverified blocks which instead must be processed by Codec

Functions

func RegisterApricotBlockTypes

func RegisterApricotBlockTypes(targetCodec codec.Registry) error

RegisterApricotBlockTypes allows registering relevant type of blocks package in the right sequence. Following repackaging of platformvm package, a few subpackage-level codecs were introduced, each handling serialization of specific types.

func RegisterBanffBlockTypes

func RegisterBanffBlockTypes(targetCodec codec.Registry) error

Types

type ApricotAbortBlock

type ApricotAbortBlock struct {
	CommonBlock `serialize:"true"`
}

func NewApricotAbortBlock

func NewApricotAbortBlock(
	parentID ids.ID,
	height uint64,
) (*ApricotAbortBlock, error)

NewApricotAbortBlock is kept for testing purposes only. Following Banff activation and subsequent code cleanup, Apricot Abort blocks should be only verified (upon bootstrap), never created anymore

func (*ApricotAbortBlock) InitCtx

func (*ApricotAbortBlock) InitCtx(*snow.Context)

func (*ApricotAbortBlock) Txs

func (*ApricotAbortBlock) Txs() []*txs.Tx

func (*ApricotAbortBlock) Visit

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

type ApricotAtomicBlock

type ApricotAtomicBlock struct {
	CommonBlock `serialize:"true"`
	Tx          *txs.Tx `serialize:"true" json:"tx"`
}

ApricotAtomicBlock being accepted results in the atomic transaction contained in the block to be accepted and committed to the chain.

func NewApricotAtomicBlock

func NewApricotAtomicBlock(
	parentID ids.ID,
	height uint64,
	tx *txs.Tx,
) (*ApricotAtomicBlock, error)

func (*ApricotAtomicBlock) InitCtx

func (b *ApricotAtomicBlock) InitCtx(ctx *snow.Context)

func (*ApricotAtomicBlock) Txs

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

func (*ApricotAtomicBlock) Visit

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

type ApricotCommitBlock

type ApricotCommitBlock struct {
	CommonBlock `serialize:"true"`
}

func NewApricotCommitBlock

func NewApricotCommitBlock(
	parentID ids.ID,
	height uint64,
) (*ApricotCommitBlock, error)

func (*ApricotCommitBlock) InitCtx

func (*ApricotCommitBlock) InitCtx(*snow.Context)

func (*ApricotCommitBlock) Txs

func (*ApricotCommitBlock) Txs() []*txs.Tx

func (*ApricotCommitBlock) Visit

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

type ApricotProposalBlock

type ApricotProposalBlock struct {
	CommonBlock `serialize:"true"`
	Tx          *txs.Tx `serialize:"true" json:"tx"`
}

func NewApricotProposalBlock

func NewApricotProposalBlock(
	parentID ids.ID,
	height uint64,
	tx *txs.Tx,
) (*ApricotProposalBlock, error)

NewApricotProposalBlock is kept for testing purposes only. Following Banff activation and subsequent code cleanup, Apricot Proposal blocks should be only verified (upon bootstrap), never created anymore

func (*ApricotProposalBlock) InitCtx

func (b *ApricotProposalBlock) InitCtx(ctx *snow.Context)

func (*ApricotProposalBlock) Txs

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

func (*ApricotProposalBlock) Visit

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

type ApricotStandardBlock

type ApricotStandardBlock struct {
	CommonBlock  `serialize:"true"`
	Transactions []*txs.Tx `serialize:"true" json:"txs"`
}

func NewApricotStandardBlock

func NewApricotStandardBlock(
	parentID ids.ID,
	height uint64,
	txs []*txs.Tx,
) (*ApricotStandardBlock, error)

NewApricotStandardBlock is kept for testing purposes only. Following Banff activation and subsequent code cleanup, Apricot Standard blocks should be only verified (upon bootstrap), never created anymore

func (*ApricotStandardBlock) InitCtx

func (b *ApricotStandardBlock) InitCtx(ctx *snow.Context)

func (*ApricotStandardBlock) Txs

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

func (*ApricotStandardBlock) Visit

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

type BanffAbortBlock

type BanffAbortBlock struct {
	Time              uint64 `serialize:"true" json:"time"`
	ApricotAbortBlock `serialize:"true"`
}

func NewBanffAbortBlock

func NewBanffAbortBlock(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
) (*BanffAbortBlock, error)

func (*BanffAbortBlock) Timestamp

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

func (*BanffAbortBlock) Visit

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

type BanffBlock

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

type BanffCommitBlock

type BanffCommitBlock struct {
	Time               uint64 `serialize:"true" json:"time"`
	ApricotCommitBlock `serialize:"true"`
}

func NewBanffCommitBlock

func NewBanffCommitBlock(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
) (*BanffCommitBlock, error)

func (*BanffCommitBlock) Timestamp

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

func (*BanffCommitBlock) Visit

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

type BanffProposalBlock

type BanffProposalBlock struct {
	Time uint64 `serialize:"true" json:"time"`
	// Transactions is currently unused. This is populated so that introducing
	// them in the future will not require a codec change.
	//
	// TODO: when Transactions is used, we must correctly verify and apply their
	//       changes.
	Transactions         []*txs.Tx `serialize:"true" json:"-"`
	ApricotProposalBlock `serialize:"true"`
}

func NewBanffProposalBlock

func NewBanffProposalBlock(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
	tx *txs.Tx,
) (*BanffProposalBlock, error)

func (*BanffProposalBlock) InitCtx

func (b *BanffProposalBlock) InitCtx(ctx *snow.Context)

func (*BanffProposalBlock) Timestamp

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

func (*BanffProposalBlock) Visit

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

type BanffStandardBlock

type BanffStandardBlock struct {
	Time                 uint64 `serialize:"true" json:"time"`
	ApricotStandardBlock `serialize:"true"`
}

func NewBanffStandardBlock

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

func (*BanffStandardBlock) Timestamp

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

func (*BanffStandardBlock) Visit

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

type Block

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

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

	// Visit calls [visitor] with this block's concrete type
	Visit(visitor Visitor) error
	// contains filtered or unexported methods
}

Block defines the common stateless interface for all blocks

func Parse

func Parse(c codec.Manager, b []byte) (Block, error)

type CommonBlock

type CommonBlock struct {
	// parent's ID
	PrntID ids.ID `serialize:"true" json:"parentID"`

	// This block's height. The genesis block is at height 0.
	Hght uint64 `serialize:"true" json:"height"`

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

CommonBlock contains fields and methods common to all blocks in this VM.

func (*CommonBlock) Bytes

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

func (*CommonBlock) Height

func (b *CommonBlock) Height() uint64

func (*CommonBlock) ID

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

func (*CommonBlock) Parent

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

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

func (m *MockBlock) InitCtx(arg0 *snow.Context)

InitCtx mocks base method.

func (*MockBlock) Parent

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

Parent mocks base method.

func (*MockBlock) Txs

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

Txs mocks base method.

func (*MockBlock) Visit

func (m *MockBlock) Visit(arg0 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) 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) InitCtx

func (mr *MockBlockMockRecorder) InitCtx(arg0 interface{}) *gomock.Call

InitCtx indicates an expected call of InitCtx.

func (*MockBlockMockRecorder) Parent

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

Parent indicates an expected call of Parent.

func (*MockBlockMockRecorder) Txs

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

Txs indicates an expected call of Txs.

func (*MockBlockMockRecorder) Visit

func (mr *MockBlockMockRecorder) Visit(arg0 interface{}) *gomock.Call

Visit indicates an expected call of Visit.

type Visitor

type Visitor interface {
	BanffAbortBlock(*BanffAbortBlock) error
	BanffCommitBlock(*BanffCommitBlock) error
	BanffProposalBlock(*BanffProposalBlock) error
	BanffStandardBlock(*BanffStandardBlock) error

	ApricotAbortBlock(*ApricotAbortBlock) error
	ApricotCommitBlock(*ApricotCommitBlock) error
	ApricotProposalBlock(*ApricotProposalBlock) error
	ApricotStandardBlock(*ApricotStandardBlock) error
	ApricotAtomicBlock(*ApricotAtomicBlock) error
}

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