blocks

package
v1.0.0-test Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package blocks 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 omegavm 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) AccumulatedFee

func (b *ApricotAbortBlock) AccumulatedFee(ids.ID) uint64

func (*ApricotAbortBlock) FeeFromAChain

func (b *ApricotAbortBlock) FeeFromAChain() uint64

func (*ApricotAbortBlock) FeeFromDChain

func (b *ApricotAbortBlock) FeeFromDChain() uint64

func (*ApricotAbortBlock) FeeFromOChain

func (b *ApricotAbortBlock) FeeFromOChain(ids.ID) uint64

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

func (b *ApricotAtomicBlock) AccumulatedFee(ids.ID) uint64

func (*ApricotAtomicBlock) FeeFromAChain

func (b *ApricotAtomicBlock) FeeFromAChain() uint64

func (*ApricotAtomicBlock) FeeFromDChain

func (b *ApricotAtomicBlock) FeeFromDChain() uint64

func (*ApricotAtomicBlock) FeeFromOChain

func (b *ApricotAtomicBlock) FeeFromOChain(ids.ID) uint64

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

func (b *ApricotCommitBlock) AccumulatedFee(ids.ID) uint64

func (*ApricotCommitBlock) FeeFromAChain

func (b *ApricotCommitBlock) FeeFromAChain() uint64

func (*ApricotCommitBlock) FeeFromDChain

func (b *ApricotCommitBlock) FeeFromDChain() uint64

func (*ApricotCommitBlock) FeeFromOChain

func (b *ApricotCommitBlock) FeeFromOChain(ids.ID) uint64

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"`
	FeeAChain   uint64  `serialize:"true" json:"feeFromAChain"`
	FeeDChain   uint64  `serialize:"true" json:"feeFromDChain"`
}

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

func (b *ApricotProposalBlock) AccumulatedFee(assetID ids.ID) uint64

func (*ApricotProposalBlock) FeeFromAChain

func (b *ApricotProposalBlock) FeeFromAChain() uint64

func (*ApricotProposalBlock) FeeFromDChain

func (b *ApricotProposalBlock) FeeFromDChain() uint64

func (*ApricotProposalBlock) FeeFromOChain

func (b *ApricotProposalBlock) FeeFromOChain(assetID ids.ID) uint64

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"`
	FeeAChain    uint64    `serialize:"true" json:"feeFromAChain"`
	FeeDChain    uint64    `serialize:"true" json:"feeFromDChain"`
}

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

func (b *ApricotStandardBlock) AccumulatedFee(assetID ids.ID) uint64

func (*ApricotStandardBlock) FeeFromAChain

func (b *ApricotStandardBlock) FeeFromAChain() uint64

func (*ApricotStandardBlock) FeeFromDChain

func (b *ApricotStandardBlock) FeeFromDChain() uint64

func (*ApricotStandardBlock) FeeFromOChain

func (b *ApricotStandardBlock) FeeFromOChain(assetID ids.ID) uint64

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 NewBanffProposalBlockWithFee

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

func (*BanffProposalBlock) FeeFromOChain

func (b *BanffProposalBlock) FeeFromOChain(assetID ids.ID) uint64

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 NewBanffStandardBlockWithFee

func NewBanffStandardBlockWithFee(
	timestamp time.Time,
	parentID ids.ID,
	height uint64,
	txs []*txs.Tx,
	feeFromAChain uint64,
	feeFromDChain uint64,
) (*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

	FeeFromOChain(ids.ID) uint64
	FeeFromAChain() uint64
	FeeFromDChain() uint64
	AccumulatedFee(ids.ID) uint64
	// 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) AccumulatedFee

func (m *MockBlock) AccumulatedFee(arg0 ids.ID) uint64

AccumulatedFee mocks base method.

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

func (m *MockBlock) FeeFromAChain() uint64

FeeFromAChain mocks base method.

func (*MockBlock) FeeFromDChain

func (m *MockBlock) FeeFromDChain() uint64

FeeFromDChain mocks base method.

func (*MockBlock) FeeFromOChain

func (m *MockBlock) FeeFromOChain(arg0 ids.ID) uint64

FeeFromOChain mocks base method.

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

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

AccumulatedFee indicates an expected call of AccumulatedFee.

func (*MockBlockMockRecorder) Bytes

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

Bytes indicates an expected call of Bytes.

func (*MockBlockMockRecorder) FeeFromAChain

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

FeeFromAChain indicates an expected call of FeeFromAChain.

func (*MockBlockMockRecorder) FeeFromDChain

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

FeeFromDChain indicates an expected call of FeeFromDChain.

func (*MockBlockMockRecorder) FeeFromOChain

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

FeeFromOChain indicates an expected call of FeeFromOChain.

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