vertex

package
v0.6.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAGVM

type DAGVM interface {
	common.VM

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

	// Retrieve a transaction that was submitted previously
	GetTx(ids.ID) (snowstorm.Tx, error)
}

DAGVM defines the minimum functionality that an avalanche VM must implement

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 {
	// Create a new vertex from the contents of a vertex
	BuildVertex(parentIDs ids.Set, txs []snowstorm.Tx) (avalanche.Vertex, error)

	// Attempt to convert a stream of bytes into a vertex
	ParseVertex(vertex []byte) (avalanche.Vertex, error)

	// GetVertex attempts to load a vertex by hash from storage
	GetVertex(vtxID ids.ID) (avalanche.Vertex, error)

	// Edge returns a list of accepted vertex IDs with no accepted children
	Edge() (vtxIDs []ids.ID)
}

Manager defines the persistant storage that is required by the consensus engine

type TestManager

type TestManager struct {
	T *testing.T

	CantParseVertex, CantBuildVertex, CantGetVertex, CantEdge bool

	ParseVertexF func([]byte) (avalanche.Vertex, error)
	BuildVertexF func(ids.Set, []snowstorm.Tx) (avalanche.Vertex, error)
	GetVertexF   func(ids.ID) (avalanche.Vertex, error)
	EdgeF        func() []ids.ID
}

TestManager ...

func (*TestManager) BuildVertex

func (m *TestManager) BuildVertex(set ids.Set, txs []snowstorm.Tx) (avalanche.Vertex, error)

BuildVertex ...

func (*TestManager) Default

func (m *TestManager) Default(cant bool)

Default ...

func (*TestManager) Edge

func (m *TestManager) Edge() []ids.ID

Edge ...

func (*TestManager) GetVertex

func (m *TestManager) GetVertex(id ids.ID) (avalanche.Vertex, error)

GetVertex ...

func (*TestManager) ParseVertex

func (m *TestManager) ParseVertex(b []byte) (avalanche.Vertex, error)

ParseVertex ...

type TestVM

type TestVM struct {
	common.TestVM

	CantPendingTxs, CantParseTx, CantIssueTx, CantGetTx bool

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

TestVM ...

func (*TestVM) Default

func (vm *TestVM) Default(cant bool)

Default ...

func (*TestVM) GetTx

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

GetTx ...

func (*TestVM) IssueTx

func (vm *TestVM) IssueTx(b []byte, issued, finalized func(choices.Status)) (ids.ID, error)

IssueTx ...

func (*TestVM) ParseTx

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

ParseTx ...

func (*TestVM) PendingTxs

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

PendingTxs ...

Jump to

Keyboard shortcuts

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