Help us shape the future of Go! Take the 2026 Go Developer Survey

dag

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	core.Engine

	// Initialize this engine.
	Initialize(ctx context.Context, params Parameters) error

	// GetVertex retrieves a vertex by its ID.
	GetVertex(vtxID ids.ID) (Vertex, error)

	// GetVtx retrieves a vertex by its ID.
	GetVtx(vtxID ids.ID) (Vertex, error)

	// Issued returns true if the vertex has been issued.
	Issued(vtx Vertex) bool

	// StopVertexAccepted returns true if all new vertices should be rejected.
	StopVertexAccepted() bool
}

Engine is a DAG consensus engine.

type Manager

type Manager interface {
	Storage

	// Add a vertex to the DAG.
	Add(vtx Vertex) error

	// Remove a vertex from the DAG.
	Remove(vtxID ids.ID) error

	// GetAncestors returns the ancestors of a vertex.
	GetAncestors(vtxID ids.ID) ([]ids.ID, error)

	// GetDescendants returns the descendants of a vertex.
	GetDescendants(vtxID ids.ID) ([]ids.ID, error)
}

Manager manages vertices in the DAG.

type Parameters

type Parameters struct {
	// Parents is the number of parents a vertex should have.
	Parents int

	// BatchSize is the number of vertices to batch together.
	BatchSize int

	// The consensus parameters.
	ConsensusParams interface{}
}

Parameters defines the parameters for the DAG consensus engine.

type Storage

type Storage interface {
	// Get a vertex by its ID.
	GetVertex(vtxID ids.ID) (Vertex, error)

	// Put a vertex into storage.
	PutVertex(vtx Vertex) error

	// HasVertex returns true if the vertex exists in storage.
	HasVertex(vtxID ids.ID) bool

	// Edge returns the edge from source to destination.
	Edge(src, dst ids.ID) bool

	// SetEdge sets an edge from source to destination.
	SetEdge(src, dst ids.ID) error
}

Storage defines the storage interface for the DAG engine.

type Vertex

type Vertex interface {
	choices.Decidable

	// Vertex returns the unique ID of this vertex.
	Vertex() ids.ID

	// Parents returns the parents of this vertex.
	Parents() []ids.ID

	// Height returns the height of this vertex.
	Height() uint64

	// Epoch returns the epoch of this vertex.
	Epoch() uint32

	// Verify that this vertex is valid.
	Verify(context.Context) error

	// Bytes returns the byte representation of this vertex.
	Bytes() []byte
}

Vertex is a vertex in the DAG.

Directories

Path Synopsis
vertexmock
Package vertexmock is a generated GoMock package.
Package vertexmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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