vertex

package
v1.7.17-rc.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSortedAndUniqueHashOf

func IsSortedAndUniqueHashOf(bytesSlice [][]byte) bool

func SortHashOf

func SortHashOf(bytesSlice [][]byte)

Types

type Builder

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

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

type DAGVM

type DAGVM interface {
	common.VM
	Getter

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

	// Convert a stream of bytes to a transaction or return an error
	ParseTx(tx []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(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 Parser

type Parser interface {
	// Parse a vertex from a slice of bytes
	ParseVtx(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(vtxID ids.ID) (avalanche.Vertex, error)
	// Edge returns a list of accepted vertex IDs with no accepted children.
	Edge() (vtxIDs []ids.ID)
	// Returns "true" if accepted frontier ("Edge") is stop vertex.
	StopVertexAccepted() (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(parentIDs []ids.ID, txs []snowstorm.Tx) (avalanche.Vertex, error)
	BuildStopVtxF func(parentIDs []ids.ID) (avalanche.Vertex, error)
}

func (*TestBuilder) BuildStopVtx

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

func (*TestBuilder) BuildVtx

func (b *TestBuilder) BuildVtx(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([]byte) (avalanche.Vertex, error)
}

func (*TestParser) Default

func (p *TestParser) Default(cant bool)

func (*TestParser) ParseVtx

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

type TestStorage

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

func (*TestStorage) Default

func (s *TestStorage) Default(cant bool)

func (*TestStorage) Edge

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

func (*TestStorage) GetVtx

func (s *TestStorage) GetVtx(id ids.ID) (avalanche.Vertex, error)

func (*TestStorage) StopVertexAccepted added in v1.8.4

func (s *TestStorage) StopVertexAccepted() (bool, error)

type TestVM

type TestVM struct {
	common.TestVM

	CantPendingTxs, CantParse, CantGet bool

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

func (*TestVM) Default

func (vm *TestVM) Default(cant bool)

func (*TestVM) GetTx

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

func (*TestVM) ParseTx

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

func (*TestVM) PendingTxs

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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