dag

package
v1.22.46 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

Package dag provides DAG consensus functionality

Package dag implements consensus for Directed Acyclic Graphs.

DAG handles parallel transactions with causal dependencies, where vertices can reference multiple parents. The consensus pipeline flows: photon → wave → focus → (prism + horizon) → flare → nebula. This enables concurrent transaction processing while respecting causality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAGConsensus added in v1.21.3

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

DAGConsensus implements real Lux consensus for DAG structures using Photon → Wave → Prism

func NewDAGConsensus added in v1.21.3

func NewDAGConsensus(k, alpha, beta int) *DAGConsensus

NewDAGConsensus creates a real consensus engine for DAG

func (*DAGConsensus) AddVertex added in v1.21.3

func (d *DAGConsensus) AddVertex(ctx context.Context, vertex *Vertex) error

AddVertex adds a vertex to the DAG

func (*DAGConsensus) Frontier added in v1.21.3

func (d *DAGConsensus) Frontier() []ids.ID

Frontier returns the current frontier vertices

func (*DAGConsensus) GetConflicting added in v1.21.3

func (d *DAGConsensus) GetConflicting(ctx context.Context, vertex *Vertex) []*Vertex

GetConflicting returns vertices that conflict with the given vertex

func (*DAGConsensus) GetVertex added in v1.21.3

func (d *DAGConsensus) GetVertex(vertexID ids.ID) (*Vertex, bool)

GetVertex returns a vertex by ID

func (*DAGConsensus) IsAccepted added in v1.21.3

func (d *DAGConsensus) IsAccepted(vertexID ids.ID) bool

IsAccepted checks if a vertex is accepted

func (*DAGConsensus) IsRejected added in v1.21.3

func (d *DAGConsensus) IsRejected(vertexID ids.ID) bool

IsRejected checks if a vertex is rejected

func (*DAGConsensus) Poll added in v1.21.3

func (d *DAGConsensus) Poll(ctx context.Context, responses map[ids.ID]int) error

Poll conducts a consensus poll

func (*DAGConsensus) Preference added in v1.21.3

func (d *DAGConsensus) Preference() ids.ID

Preference returns current preferred vertex

func (*DAGConsensus) ProcessVote added in v1.21.3

func (d *DAGConsensus) ProcessVote(ctx context.Context, vertexID ids.ID, accept bool) error

ProcessVote processes a vote for a vertex

func (*DAGConsensus) ResolveConflict added in v1.21.3

func (d *DAGConsensus) ResolveConflict(ctx context.Context, vertices []*Vertex) (*Vertex, error)

ResolveConflict resolves conflicts between vertices using Lux consensus with Prism DAG refraction

func (*DAGConsensus) Stats added in v1.21.3

func (d *DAGConsensus) Stats() map[string]interface{}

Stats returns consensus statistics

type Engine

type Engine interface {
	// GetVtx gets a vertex by ID
	GetVtx(context.Context, ids.ID) (Transaction, error)

	// BuildVtx builds a new vertex
	BuildVtx(context.Context) (Transaction, error)

	// ParseVtx parses a vertex from bytes
	ParseVtx(context.Context, []byte) (Transaction, error)

	// Start starts the engine
	Start(context.Context, uint32) error

	// Shutdown shuts down the engine
	Shutdown(context.Context) error
}

Engine defines the DAG consensus engine interface

func New

func New() Engine

New creates a new DAG engine with real Lux consensus

func NewWithParams added in v1.21.3

func NewWithParams(params config.Parameters) Engine

NewWithParams creates an engine with specific parameters

type Transaction

type Transaction interface {
	ID() ids.ID
	Parent() ids.ID
	Height() uint64
	Bytes() []byte
	Verify(context.Context) error
	Accept(context.Context) error
	Reject(context.Context) error
}

Transaction represents a DAG transaction

type Tx

type Tx interface {
	ID() ids.ID
	ParentIDs() []ids.ID
	Bytes() []byte
	Verify(context.Context) error
	Accept(context.Context) error
	Reject(context.Context) error
}

Tx represents a transaction in the DAG

type Vertex added in v1.21.3

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

Vertex represents a vertex in the DAG

func NewVertex added in v1.21.3

func NewVertex(id ids.ID, parentIDs []ids.ID, height uint64, timestamp int64, data []byte) *Vertex

NewVertex creates a new vertex

func (*Vertex) Accept added in v1.21.3

func (v *Vertex) Accept(ctx context.Context) error

Accept accepts the vertex

func (*Vertex) AddChild added in v1.21.3

func (v *Vertex) AddChild(child *Vertex)

AddChild adds a child vertex

func (*Vertex) AddParent added in v1.21.3

func (v *Vertex) AddParent(parent *Vertex)

AddParent adds a parent vertex

func (*Vertex) Bytes added in v1.21.3

func (v *Vertex) Bytes() []byte

Bytes returns the vertex data

func (*Vertex) Children added in v1.21.3

func (v *Vertex) Children() []*Vertex

Children returns all child vertices

func (*Vertex) Height added in v1.21.3

func (v *Vertex) Height() uint64

Height returns the vertex height

func (*Vertex) ID added in v1.21.3

func (v *Vertex) ID() ids.ID

ID returns the vertex ID

func (*Vertex) IsAccepted added in v1.21.3

func (v *Vertex) IsAccepted() bool

IsAccepted returns whether the vertex is accepted

func (*Vertex) IsProcessing added in v1.21.3

func (v *Vertex) IsProcessing() bool

IsProcessing returns whether the vertex is being processed

func (*Vertex) IsRejected added in v1.21.3

func (v *Vertex) IsRejected() bool

IsRejected returns whether the vertex is rejected

func (*Vertex) LuxConsensus added in v1.21.3

func (v *Vertex) LuxConsensus() *engine.LuxConsensus

LuxConsensus returns the Lux consensus instance

func (*Vertex) Parent added in v1.21.3

func (v *Vertex) Parent() ids.ID

Parent returns the first parent ID (for interface compatibility)

func (*Vertex) ParentIDs added in v1.21.3

func (v *Vertex) ParentIDs() []ids.ID

ParentIDs returns all parent IDs

func (*Vertex) Parents added in v1.21.3

func (v *Vertex) Parents() []*Vertex

Parents returns all parent vertices

func (*Vertex) Reject added in v1.21.3

func (v *Vertex) Reject(ctx context.Context) error

Reject rejects the vertex

func (*Vertex) SetLuxConsensus added in v1.21.3

func (v *Vertex) SetLuxConsensus(lc *engine.LuxConsensus)

SetLuxConsensus sets the Lux consensus instance for this vertex

func (*Vertex) SetProcessing added in v1.21.3

func (v *Vertex) SetProcessing(processing bool)

SetProcessing sets the processing state

func (*Vertex) Verify added in v1.21.3

func (v *Vertex) Verify(ctx context.Context) error

Verify verifies the vertex

Directories

Path Synopsis
queue
Package queue provides a simple blocking queue for DAG bootstrap
Package queue provides a simple blocking queue for DAG bootstrap

Jump to

Keyboard shortcuts

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