interfaces

package
v1.22.25 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: BSD-3-Clause Imports: 3 Imported by: 8

Documentation

Overview

Package interfaces defines core consensus interfaces

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BCLookup added in v1.21.0

type BCLookup interface {
	// Lookup returns the blockchain ID for an alias
	Lookup(alias string) (ids.ID, error)
	// GetAlias returns the alias for a blockchain ID
	GetAlias(blockchainID ids.ID) (string, error)
	// GetBlockchainID returns the blockchain ID for an alias
	GetBlockchainID(alias string) (ids.ID, error)
	// PrimaryAlias returns the primary alias for a blockchain
	PrimaryAlias(blockchainID ids.ID) (string, error)
	// Aliases returns all aliases for a blockchain
	Aliases(blockchainID ids.ID) ([]string, error)
}

BCLookup provides blockchain lookup functionality

type Block

type Block interface {
	// ID returns the block's unique identifier
	ID() ids.ID

	// Parent returns the parent block's ID
	Parent() ids.ID

	// Height returns the block's height
	Height() uint64

	// Bytes returns the serialized block
	Bytes() []byte

	// Accept marks the block as accepted
	Accept(context.Context) error

	// Reject marks the block as rejected
	Reject(context.Context) error
}

Block represents a consensus block

type SharedMemory added in v1.21.0

type SharedMemory interface {
	GetDatabase(id ids.ID) (*VersionedDatabase, database.Database)
	ReleaseDatabase(id ids.ID) error
}

SharedMemory provides shared memory functionality

type State

type State interface {
	// GetBlock retrieves a block by its ID
	GetBlock(ctx context.Context, blockID ids.ID) (Block, error)

	// PutBlock stores a block
	PutBlock(ctx context.Context, block Block) error

	// GetLastAccepted returns the last accepted block ID
	GetLastAccepted(ctx context.Context) (ids.ID, error)

	// SetLastAccepted sets the last accepted block ID
	SetLastAccepted(ctx context.Context, blockID ids.ID) error
}

State represents the state of the consensus

type StateEnum added in v1.21.0

type StateEnum uint8

StateEnum represents consensus state

const (
	// StateSyncing indicates the node is syncing state
	StateSyncing StateEnum = iota
	// Bootstrapping indicates the node is bootstrapping
	Bootstrapping
	// NormalOp indicates normal operation
	NormalOp
)

type StateHolder added in v1.21.0

type StateHolder interface {
	// GetState returns the current state
	GetState() StateEnum
}

StateHolder holds state information

type VersionedDatabase added in v1.21.0

type VersionedDatabase struct {
	Lock   database.Database
	Memory database.Database
}

VersionedDatabase provides versioned database access

Jump to

Keyboard shortcuts

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