nova

package
v1.22.45 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package nova provides linear blockchain consensus mode.

Nova implements classic linear chain consensus where blocks extend sequentially. It wraps the ray engine to provide blockchain-specific semantics: height tracking, preference management, and sequential finality.

In the cosmic metaphor, a nova is a stellar explosion - a singular, decisive event in linear time, representing the finality of each block in sequence.

Nova is designed for chains that require strict ordering and single-chain semantics, such as the P-Chain for platform operations.

Key concepts:

  • Linear progression: blocks extend a single chain
  • Sequential finality: one block finalized at a time
  • Height tracking: maintains current blockchain height
  • Preference tracking: manages preferred block selection

Usage:

cfg := nova.Config{
    SampleSize: 20,
    Alpha:      0.8,
    Beta:       15,
    RoundTO:    250 * time.Millisecond,
}
n := nova.NewNova(cfg, cut, transport, source, sink)
n.Start(ctx)

See also: ray (underlying engine), wave (voting primitive).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SampleSize  int           // k parameter for sampling
	Alpha       float64       // threshold ratio
	Beta        uint32        // confidence threshold
	RoundTO     time.Duration // round timeout
	GenesisHash [32]byte      // genesis block hash
}

Config holds configuration for Nova consensus mode

type Nova

type Nova[T comparable] struct {
	// contains filtered or unexported fields
}

Nova implements linear blockchain consensus using the internal Ray engine

func NewNova

func NewNova[T comparable](cfg Config, cut prism.Cut[T], tx wave.Transport[T], source ray.Source[T], sink ray.Sink[T]) *Nova[T]

NewNova creates a new Nova instance with Ray engine

func (*Nova[T]) GetPreference

func (n *Nova[T]) GetPreference() (T, bool)

GetPreference returns the current preferred block

func (*Nova[T]) Height

func (n *Nova[T]) Height() uint64

Height returns the current blockchain height

func (*Nova[T]) IsFinalized

func (n *Nova[T]) IsFinalized(block T) bool

IsFinalized checks if a block is finalized

func (*Nova[T]) ProposeBlock

func (n *Nova[T]) ProposeBlock(ctx context.Context, block T) error

ProposeBlock proposes a new block for the current height

func (*Nova[T]) Start

func (n *Nova[T]) Start(ctx context.Context) error

Start begins Nova consensus operation

func (*Nova[T]) Stop

func (n *Nova[T]) Stop(ctx context.Context) error

Stop ends Nova consensus operation

func (*Nova[T]) Tick

func (n *Nova[T]) Tick(ctx context.Context) error

Tick performs one consensus round for linear chain progression

Jump to

Keyboard shortcuts

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