blocks

package
v1.7.18-rc.6 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package blocks is a generated GoMock package.

Index

Constants

This section is empty.

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 RegisterBlockTypes

func RegisterBlockTypes(targetCodec codec.Registry) error

RegisterBlockTypes 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.

Types

type AbortBlock

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

func NewAbortBlock

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

func (*AbortBlock) Txs

func (ab *AbortBlock) Txs() []*txs.Tx

func (*AbortBlock) Visit

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

type AtomicBlock

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

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

func NewAtomicBlock

func NewAtomicBlock(
	parentID ids.ID,
	height uint64,
	tx *txs.Tx,
) (*AtomicBlock, error)

func (*AtomicBlock) Txs

func (ab *AtomicBlock) Txs() []*txs.Tx

func (*AtomicBlock) Visit

func (ab *AtomicBlock) Visit(v Visitor) error

type Block

type Block interface {
	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 CommitBlock

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

func NewCommitBlock

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

func (*CommitBlock) Txs

func (cb *CommitBlock) Txs() []*txs.Tx

func (*CommitBlock) Visit

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

type CommonBlock

type CommonBlock struct {
	PrntID ids.ID `serialize:"true" json:"parentID"` // parent's ID
	Hght   uint64 `serialize:"true" json:"height"`   // This block's height. The genesis block is at height 0.
	// 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) 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(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) 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) 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(visitor interface{}) *gomock.Call

Visit indicates an expected call of Visit.

type ProposalBlock

type ProposalBlock struct {
	CommonBlock `serialize:"true"`

	Tx *txs.Tx `serialize:"true" json:"tx"`
}

As is, this is duplication of atomic block. But let's tolerate some code duplication for now

func NewProposalBlock

func NewProposalBlock(
	parentID ids.ID,
	height uint64,
	tx *txs.Tx,
) (*ProposalBlock, error)

func (*ProposalBlock) Txs

func (pb *ProposalBlock) Txs() []*txs.Tx

func (*ProposalBlock) Visit

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

type StandardBlock

type StandardBlock struct {
	CommonBlock `serialize:"true"`

	Transactions []*txs.Tx `serialize:"true" json:"txs"`
}

func NewStandardBlock

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

func (*StandardBlock) Txs

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

func (*StandardBlock) Visit

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

type Visitor

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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