vertex

package
v1.9.10-rc.9 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: BSD-3-Clause Imports: 25 Imported by: 8

Documentation

Overview

Package vertex is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	// Build a new vertex from the contents of a vertex
	BuildVtx(ctx context.Context, parentIDs []ids.ID, txs []snowstorm.Tx) (avalanche.Vertex, error)
	// Build a new stop vertex from the parents
	BuildStopVtx(ctx context.Context, parentIDs []ids.ID) (avalanche.Vertex, error)
}

Builder builds a vertex given a set of parentIDs and transactions.

type DAGVM

type DAGVM interface {
	block.ChainVM
	Getter

	// Linearize is called after [Initialize] and after the DAG has been
	// finalized. After Linearize is called:
	// - PendingTxs will never be called again
	// - GetTx will never be called again
	// - ParseTx may still be called
	// - All the block based functions of the [block.ChainVM] must work as
	//   expected.
	// Linearize is part of the VM initialization, and will be called at most
	// once per VM instantiation. This means that Linearize should be called
	// every time the chain restarts after the DAG has finalized.
	Linearize(ctx context.Context, stopVertexID ids.ID) error

	// Return any transactions that have not been sent to consensus yet
	PendingTxs(ctx context.Context) []snowstorm.Tx

	// Convert a stream of bytes to a transaction or return an error
	ParseTx(ctx context.Context, txBytes []byte) (snowstorm.Tx, error)
}

DAGVM defines the minimum functionality that an avalanche VM must implement

type Getter added in v1.8.4

type Getter interface {
	// Retrieve a transaction that was submitted previously
	GetTx(ctx context.Context, txID ids.ID) (snowstorm.Tx, error)
}

Getter defines the functionality for fetching a tx/block by its ID.

type Heap

type Heap interface {
	// Empty the heap.
	Clear()

	// Add the provided vertex to the heap. Vertices are de-duplicated, returns
	// true if the vertex was added, false if it was dropped.
	Push(avalanche.Vertex) bool

	// Remove the top vertex. Assumes that there is at least one element.
	Pop() avalanche.Vertex

	// Returns if a vertex with the provided ID is currently in the heap.
	Contains(ids.ID) bool

	// Returns the number of vertices in the heap.
	Len() int
}

Heap defines the functionality of a heap of vertices with unique VertexIDs ordered by height

func NewHeap

func NewHeap() Heap

NewHeap returns an empty Heap

type Manager

type Manager interface {
	Builder
	Parser
	Storage
}

Manager defines all the vertex related functionality that is required by the consensus engine.

type MockDAGVM added in v1.9.2

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

MockDAGVM is a mock of DAGVM interface.

func NewMockDAGVM added in v1.9.2

func NewMockDAGVM(ctrl *gomock.Controller) *MockDAGVM

NewMockDAGVM creates a new mock instance.

func (*MockDAGVM) AppGossip added in v1.9.2

func (m *MockDAGVM) AppGossip(arg0 context.Context, arg1 ids.NodeID, arg2 []byte) error

AppGossip mocks base method.

func (*MockDAGVM) AppRequest added in v1.9.2

func (m *MockDAGVM) AppRequest(arg0 context.Context, arg1 ids.NodeID, arg2 uint32, arg3 time.Time, arg4 []byte) error

AppRequest mocks base method.

func (*MockDAGVM) AppRequestFailed added in v1.9.2

func (m *MockDAGVM) AppRequestFailed(arg0 context.Context, arg1 ids.NodeID, arg2 uint32) error

AppRequestFailed mocks base method.

func (*MockDAGVM) AppResponse added in v1.9.2

func (m *MockDAGVM) AppResponse(arg0 context.Context, arg1 ids.NodeID, arg2 uint32, arg3 []byte) error

AppResponse mocks base method.

func (*MockDAGVM) BuildBlock added in v1.9.8

func (m *MockDAGVM) BuildBlock(arg0 context.Context) (snowman.Block, error)

BuildBlock mocks base method.

func (*MockDAGVM) Connected added in v1.9.2

func (m *MockDAGVM) Connected(arg0 context.Context, arg1 ids.NodeID, arg2 *version.Application) error

Connected mocks base method.

func (*MockDAGVM) CreateHandlers added in v1.9.2

func (m *MockDAGVM) CreateHandlers(arg0 context.Context) (map[string]*common.HTTPHandler, error)

CreateHandlers mocks base method.

func (*MockDAGVM) CreateStaticHandlers added in v1.9.2

func (m *MockDAGVM) CreateStaticHandlers(arg0 context.Context) (map[string]*common.HTTPHandler, error)

CreateStaticHandlers mocks base method.

func (*MockDAGVM) CrossChainAppRequest added in v1.9.2

func (m *MockDAGVM) CrossChainAppRequest(arg0 context.Context, arg1 ids.ID, arg2 uint32, arg3 time.Time, arg4 []byte) error

CrossChainAppRequest mocks base method.

func (*MockDAGVM) CrossChainAppRequestFailed added in v1.9.2

func (m *MockDAGVM) CrossChainAppRequestFailed(arg0 context.Context, arg1 ids.ID, arg2 uint32) error

CrossChainAppRequestFailed mocks base method.

func (*MockDAGVM) CrossChainAppResponse added in v1.9.2

func (m *MockDAGVM) CrossChainAppResponse(arg0 context.Context, arg1 ids.ID, arg2 uint32, arg3 []byte) error

CrossChainAppResponse mocks base method.

func (*MockDAGVM) Disconnected added in v1.9.2

func (m *MockDAGVM) Disconnected(arg0 context.Context, arg1 ids.NodeID) error

Disconnected mocks base method.

func (*MockDAGVM) EXPECT added in v1.9.2

func (m *MockDAGVM) EXPECT() *MockDAGVMMockRecorder

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

func (*MockDAGVM) GetBlock added in v1.9.8

func (m *MockDAGVM) GetBlock(arg0 context.Context, arg1 ids.ID) (snowman.Block, error)

GetBlock mocks base method.

func (*MockDAGVM) GetTx added in v1.9.2

func (m *MockDAGVM) GetTx(arg0 context.Context, arg1 ids.ID) (snowstorm.Tx, error)

GetTx mocks base method.

func (*MockDAGVM) HealthCheck added in v1.9.2

func (m *MockDAGVM) HealthCheck(arg0 context.Context) (interface{}, error)

HealthCheck mocks base method.

func (*MockDAGVM) Initialize added in v1.9.2

func (m *MockDAGVM) Initialize(arg0 context.Context, arg1 *snow.Context, arg2 manager.Manager, arg3, arg4, arg5 []byte, arg6 chan<- common.Message, arg7 []*common.Fx, arg8 common.AppSender) error

Initialize mocks base method.

func (*MockDAGVM) LastAccepted added in v1.9.8

func (m *MockDAGVM) LastAccepted(arg0 context.Context) (ids.ID, error)

LastAccepted mocks base method.

func (*MockDAGVM) Linearize added in v1.9.8

func (m *MockDAGVM) Linearize(arg0 context.Context, arg1 ids.ID) error

Linearize mocks base method.

func (*MockDAGVM) ParseBlock added in v1.9.8

func (m *MockDAGVM) ParseBlock(arg0 context.Context, arg1 []byte) (snowman.Block, error)

ParseBlock mocks base method.

func (*MockDAGVM) ParseTx added in v1.9.2

func (m *MockDAGVM) ParseTx(arg0 context.Context, arg1 []byte) (snowstorm.Tx, error)

ParseTx mocks base method.

func (*MockDAGVM) PendingTxs added in v1.9.2

func (m *MockDAGVM) PendingTxs(arg0 context.Context) []snowstorm.Tx

PendingTxs mocks base method.

func (*MockDAGVM) SetPreference added in v1.9.8

func (m *MockDAGVM) SetPreference(arg0 context.Context, arg1 ids.ID) error

SetPreference mocks base method.

func (*MockDAGVM) SetState added in v1.9.2

func (m *MockDAGVM) SetState(arg0 context.Context, arg1 snow.State) error

SetState mocks base method.

func (*MockDAGVM) Shutdown added in v1.9.2

func (m *MockDAGVM) Shutdown(arg0 context.Context) error

Shutdown mocks base method.

func (*MockDAGVM) Version added in v1.9.2

func (m *MockDAGVM) Version(arg0 context.Context) (string, error)

Version mocks base method.

type MockDAGVMMockRecorder added in v1.9.2

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

MockDAGVMMockRecorder is the mock recorder for MockDAGVM.

func (*MockDAGVMMockRecorder) AppGossip added in v1.9.2

func (mr *MockDAGVMMockRecorder) AppGossip(arg0, arg1, arg2 interface{}) *gomock.Call

AppGossip indicates an expected call of AppGossip.

func (*MockDAGVMMockRecorder) AppRequest added in v1.9.2

func (mr *MockDAGVMMockRecorder) AppRequest(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call

AppRequest indicates an expected call of AppRequest.

func (*MockDAGVMMockRecorder) AppRequestFailed added in v1.9.2

func (mr *MockDAGVMMockRecorder) AppRequestFailed(arg0, arg1, arg2 interface{}) *gomock.Call

AppRequestFailed indicates an expected call of AppRequestFailed.

func (*MockDAGVMMockRecorder) AppResponse added in v1.9.2

func (mr *MockDAGVMMockRecorder) AppResponse(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

AppResponse indicates an expected call of AppResponse.

func (*MockDAGVMMockRecorder) BuildBlock added in v1.9.8

func (mr *MockDAGVMMockRecorder) BuildBlock(arg0 interface{}) *gomock.Call

BuildBlock indicates an expected call of BuildBlock.

func (*MockDAGVMMockRecorder) Connected added in v1.9.2

func (mr *MockDAGVMMockRecorder) Connected(arg0, arg1, arg2 interface{}) *gomock.Call

Connected indicates an expected call of Connected.

func (*MockDAGVMMockRecorder) CreateHandlers added in v1.9.2

func (mr *MockDAGVMMockRecorder) CreateHandlers(arg0 interface{}) *gomock.Call

CreateHandlers indicates an expected call of CreateHandlers.

func (*MockDAGVMMockRecorder) CreateStaticHandlers added in v1.9.2

func (mr *MockDAGVMMockRecorder) CreateStaticHandlers(arg0 interface{}) *gomock.Call

CreateStaticHandlers indicates an expected call of CreateStaticHandlers.

func (*MockDAGVMMockRecorder) CrossChainAppRequest added in v1.9.2

func (mr *MockDAGVMMockRecorder) CrossChainAppRequest(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call

CrossChainAppRequest indicates an expected call of CrossChainAppRequest.

func (*MockDAGVMMockRecorder) CrossChainAppRequestFailed added in v1.9.2

func (mr *MockDAGVMMockRecorder) CrossChainAppRequestFailed(arg0, arg1, arg2 interface{}) *gomock.Call

CrossChainAppRequestFailed indicates an expected call of CrossChainAppRequestFailed.

func (*MockDAGVMMockRecorder) CrossChainAppResponse added in v1.9.2

func (mr *MockDAGVMMockRecorder) CrossChainAppResponse(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

CrossChainAppResponse indicates an expected call of CrossChainAppResponse.

func (*MockDAGVMMockRecorder) Disconnected added in v1.9.2

func (mr *MockDAGVMMockRecorder) Disconnected(arg0, arg1 interface{}) *gomock.Call

Disconnected indicates an expected call of Disconnected.

func (*MockDAGVMMockRecorder) GetBlock added in v1.9.8

func (mr *MockDAGVMMockRecorder) GetBlock(arg0, arg1 interface{}) *gomock.Call

GetBlock indicates an expected call of GetBlock.

func (*MockDAGVMMockRecorder) GetTx added in v1.9.2

func (mr *MockDAGVMMockRecorder) GetTx(arg0, arg1 interface{}) *gomock.Call

GetTx indicates an expected call of GetTx.

func (*MockDAGVMMockRecorder) HealthCheck added in v1.9.2

func (mr *MockDAGVMMockRecorder) HealthCheck(arg0 interface{}) *gomock.Call

HealthCheck indicates an expected call of HealthCheck.

func (*MockDAGVMMockRecorder) Initialize added in v1.9.2

func (mr *MockDAGVMMockRecorder) Initialize(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 interface{}) *gomock.Call

Initialize indicates an expected call of Initialize.

func (*MockDAGVMMockRecorder) LastAccepted added in v1.9.8

func (mr *MockDAGVMMockRecorder) LastAccepted(arg0 interface{}) *gomock.Call

LastAccepted indicates an expected call of LastAccepted.

func (*MockDAGVMMockRecorder) Linearize added in v1.9.8

func (mr *MockDAGVMMockRecorder) Linearize(arg0, arg1 interface{}) *gomock.Call

Linearize indicates an expected call of Linearize.

func (*MockDAGVMMockRecorder) ParseBlock added in v1.9.8

func (mr *MockDAGVMMockRecorder) ParseBlock(arg0, arg1 interface{}) *gomock.Call

ParseBlock indicates an expected call of ParseBlock.

func (*MockDAGVMMockRecorder) ParseTx added in v1.9.2

func (mr *MockDAGVMMockRecorder) ParseTx(arg0, arg1 interface{}) *gomock.Call

ParseTx indicates an expected call of ParseTx.

func (*MockDAGVMMockRecorder) PendingTxs added in v1.9.2

func (mr *MockDAGVMMockRecorder) PendingTxs(arg0 interface{}) *gomock.Call

PendingTxs indicates an expected call of PendingTxs.

func (*MockDAGVMMockRecorder) SetPreference added in v1.9.8

func (mr *MockDAGVMMockRecorder) SetPreference(arg0, arg1 interface{}) *gomock.Call

SetPreference indicates an expected call of SetPreference.

func (*MockDAGVMMockRecorder) SetState added in v1.9.2

func (mr *MockDAGVMMockRecorder) SetState(arg0, arg1 interface{}) *gomock.Call

SetState indicates an expected call of SetState.

func (*MockDAGVMMockRecorder) Shutdown added in v1.9.2

func (mr *MockDAGVMMockRecorder) Shutdown(arg0 interface{}) *gomock.Call

Shutdown indicates an expected call of Shutdown.

func (*MockDAGVMMockRecorder) Version added in v1.9.2

func (mr *MockDAGVMMockRecorder) Version(arg0 interface{}) *gomock.Call

Version indicates an expected call of Version.

type Parser

type Parser interface {
	// Parse a vertex from a slice of bytes
	ParseVtx(ctx context.Context, vertex []byte) (avalanche.Vertex, error)
}

Parser parses bytes into a vertex.

type StatelessVertex

type StatelessVertex interface {
	verify.Verifiable
	ID() ids.ID
	Bytes() []byte
	Version() uint16
	ChainID() ids.ID
	StopVertex() bool
	Height() uint64
	Epoch() uint32
	ParentIDs() []ids.ID
	Txs() [][]byte
}

func Build

func Build(
	chainID ids.ID,
	height uint64,
	parentIDs []ids.ID,
	txs [][]byte,
) (StatelessVertex, error)

Build a new stateless vertex from the contents of a vertex

func BuildStopVertex

func BuildStopVertex(chainID ids.ID, height uint64, parentIDs []ids.ID) (StatelessVertex, error)

Build a new stateless vertex from the contents of a vertex

func Parse

func Parse(bytes []byte) (StatelessVertex, error)

Parse parses the provided vertex bytes into a stateless vertex

type Storage

type Storage interface {
	// Get a vertex by its hash from storage.
	GetVtx(ctx context.Context, vtxID ids.ID) (avalanche.Vertex, error)
	// Edge returns a list of accepted vertex IDs with no accepted children.
	Edge(ctx context.Context) (vtxIDs []ids.ID)
	// Returns "true" if accepted frontier ("Edge") is stop vertex.
	StopVertexAccepted(ctx context.Context) (bool, error)
}

Storage defines the persistent storage that is required by the consensus engine.

type TestBuilder

type TestBuilder struct {
	T             *testing.T
	CantBuildVtx  bool
	BuildVtxF     func(ctx context.Context, parentIDs []ids.ID, txs []snowstorm.Tx) (avalanche.Vertex, error)
	BuildStopVtxF func(ctx context.Context, parentIDs []ids.ID) (avalanche.Vertex, error)
}

func (*TestBuilder) BuildStopVtx

func (b *TestBuilder) BuildStopVtx(ctx context.Context, parentIDs []ids.ID) (avalanche.Vertex, error)

func (*TestBuilder) BuildVtx

func (b *TestBuilder) BuildVtx(ctx context.Context, parentIDs []ids.ID, txs []snowstorm.Tx) (avalanche.Vertex, error)

func (*TestBuilder) Default

func (b *TestBuilder) Default(cant bool)

type TestManager

type TestManager struct {
	TestBuilder
	TestParser
	TestStorage
}

func NewTestManager

func NewTestManager(t *testing.T) *TestManager

func (*TestManager) Default

func (m *TestManager) Default(cant bool)

type TestParser

type TestParser struct {
	T            *testing.T
	CantParseVtx bool
	ParseVtxF    func(context.Context, []byte) (avalanche.Vertex, error)
}

func (*TestParser) Default

func (p *TestParser) Default(cant bool)

func (*TestParser) ParseVtx

func (p *TestParser) ParseVtx(ctx context.Context, b []byte) (avalanche.Vertex, error)

type TestStorage

type TestStorage struct {
	T                                            *testing.T
	CantGetVtx, CantEdge, CantStopVertexAccepted bool
	GetVtxF                                      func(context.Context, ids.ID) (avalanche.Vertex, error)
	EdgeF                                        func(context.Context) []ids.ID
	StopVertexAcceptedF                          func(context.Context) (bool, error)
}

func (*TestStorage) Default

func (s *TestStorage) Default(cant bool)

func (*TestStorage) Edge

func (s *TestStorage) Edge(ctx context.Context) []ids.ID

func (*TestStorage) GetVtx

func (s *TestStorage) GetVtx(ctx context.Context, vtxID ids.ID) (avalanche.Vertex, error)

func (*TestStorage) StopVertexAccepted added in v1.8.4

func (s *TestStorage) StopVertexAccepted(ctx context.Context) (bool, error)

type TestVM

type TestVM struct {
	block.TestVM

	CantLinearize, CantPendingTxs, CantParse, CantGet bool

	LinearizeF  func(context.Context, ids.ID) error
	PendingTxsF func(context.Context) []snowstorm.Tx
	ParseTxF    func(context.Context, []byte) (snowstorm.Tx, error)
	GetTxF      func(context.Context, ids.ID) (snowstorm.Tx, error)
}

func (*TestVM) Default

func (vm *TestVM) Default(cant bool)

func (*TestVM) GetTx

func (vm *TestVM) GetTx(ctx context.Context, txID ids.ID) (snowstorm.Tx, error)

func (*TestVM) Linearize added in v1.9.6

func (vm *TestVM) Linearize(ctx context.Context, stopVertexID ids.ID) error

func (*TestVM) ParseTx

func (vm *TestVM) ParseTx(ctx context.Context, b []byte) (snowstorm.Tx, error)

func (*TestVM) PendingTxs

func (vm *TestVM) PendingTxs(ctx context.Context) []snowstorm.Tx

Jump to

Keyboard shortcuts

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