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

qchain

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainListener

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

ChainListener allows chains to listen for Q-blocks affecting them.

func NewChainListener

func NewChainListener(chainID ids.ID, qchain *QChain) *ChainListener

NewChainListener creates a listener for a specific chain.

func (*ChainListener) Listen

func (l *ChainListener) Listen(ctx context.Context, handler func(QBlock) error) error

Listen processes Q-blocks for this chain.

type Manager

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

Manager manages Q-Chain integration with P-Chain.

func NewManager

func NewManager(db database.Database, pchain interface{}) *Manager

NewManager creates a new Q-Chain manager.

func (*Manager) GetQChain

func (m *Manager) GetQChain() *QChain

GetQChain returns the Q-Chain instance.

func (*Manager) ProcessPChainBlock

func (m *Manager) ProcessPChainBlock(ctx context.Context, pBlockID ids.ID, pHeight uint64, txs []interface{}) error

ProcessPChainBlock processes a P-Chain block for Q-blocks.

type QBlock

type QBlock struct {

	// Core Q-block fields (placeholder)
	QBlockID  ids.ID
	Height    uint64
	VertexIDs []ids.ID

	// P-Chain integration
	PChainBlockID ids.ID    // P-Chain block containing this Q-block
	PChainHeight  uint64    // P-Chain block height
	InclusionTime time.Time // When included in P-Chain

	// Validator set at this height
	ValidatorSet map[ids.NodeID]uint64 // NodeID -> stake weight
}

QBlock extends the core Q-block with P-Chain integration.

type QBlockTransaction

type QBlockTransaction struct {
	// TODO: Use quasarcore.QBlock when available
	QBlockID   ids.ID
	Height     uint64
	VertexIDs  []ids.ID
	Signatures [][]byte // Validator signatures
}

QBlockTransaction represents a Q-block embedded in a P-Chain transaction.

type QChain

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

QChain manages Q-blocks embedded in the P-Chain. It provides network-wide quantum finality for all chains.

func NewQChain

func NewQChain(db database.Database) *QChain

NewQChain creates a new Q-Chain instance.

func (*QChain) AddQBlock

func (q *QChain) AddQBlock(ctx context.Context, qBlockID ids.ID, height uint64, vertexIDs []ids.ID, pChainBlockID ids.ID, pChainHeight uint64) error

AddQBlock adds a new Q-block from Quasar consensus.

func (*QChain) GetFinalizedVertices

func (q *QChain) GetFinalizedVertices(height uint64) ([]ids.ID, error)

GetFinalizedVertices returns all vertices finalized at a given height.

func (*QChain) GetLastQBlock

func (q *QChain) GetLastQBlock() (*QBlock, bool)

GetLastQBlock returns the most recent Q-block.

func (*QChain) GetQBlock

func (q *QChain) GetQBlock(qBlockID ids.ID) (*QBlock, error)

GetQBlock retrieves a Q-block by ID.

func (*QChain) GetQBlockByHeight

func (q *QChain) GetQBlockByHeight(height uint64) (*QBlock, error)

GetQBlockByHeight retrieves a Q-block by height.

func (*QChain) Subscribe

func (q *QChain) Subscribe() <-chan QBlock

Subscribe registers a callback for new Q-blocks.

func (*QChain) Unsubscribe

func (q *QChain) Unsubscribe(ch <-chan QBlock)

Unsubscribe removes a Q-block subscription.

type QChainState

type QChainState interface {
	// GetQBlock retrieves a Q-block by ID.
	GetQBlock(qBlockID ids.ID) (*QBlock, error)

	// GetQBlockByHeight retrieves a Q-block by height.
	GetQBlockByHeight(height uint64) (*QBlock, error)

	// GetLastQBlock returns the most recent Q-block.
	GetLastQBlock() (*QBlock, bool)

	// GetFinalizedVertices returns vertices finalized at a height.
	GetFinalizedVertices(height uint64) ([]ids.ID, error)
}

QChainState provides read-only access to Q-Chain state.

Jump to

Keyboard shortcuts

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