Documentation
¶
Overview ¶
Package dag provides shared DAG indexing for LUX chains (X, A, B, Q, T, Z). Based on luxfi/consensus/engine/dag/vertex - multiple parents per vertex.
Index ¶
- type Adapter
- type ChainType
- type Config
- type Edge
- type EdgeType
- type Indexer
- func (idx *Indexer) Init(ctx context.Context) error
- func (idx *Indexer) Run(ctx context.Context) error
- func (idx *Indexer) Store() storage.Store
- func (idx *Indexer) StoreEdge(ctx context.Context, e Edge) error
- func (idx *Indexer) StoreVertex(ctx context.Context, v *Vertex) error
- func (idx *Indexer) UpdateStats(ctx context.Context) error
- type Poller
- type Stats
- type Status
- type Subscriber
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
ParseVertex(data json.RawMessage) (*Vertex, error)
GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)
GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
InitSchema(ctx context.Context, store storage.Store) error
GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
}
Adapter interface for chain-specific logic
type ChainType ¶
type ChainType string
ChainType identifies the DAG chain
const ( ChainX ChainType = "xchain" // Exchange - assets, UTXOs ChainA ChainType = "achain" // AI - attestations, compute ChainB ChainType = "bchain" // Bridge - cross-chain ChainQ ChainType = "qchain" // Quantum - finality proofs ChainT ChainType = "tchain" // Teleport - MPC signatures ChainZ ChainType = "zchain" // Privacy - ZK transactions (DAG for fast consensus, proofs for privacy) ChainK ChainType = "kchain" // KMS - Post-quantum key material )
type Config ¶
type Config struct {
ChainType ChainType
ChainName string
RPCEndpoint string
RPCMethod string // xvm, bvm, qvm, tvm
HTTPPort int
PollInterval time.Duration
DataDir string // For default storage, defaults to ~/.lux/indexer/<chain>
}
Config for DAG indexer
type Edge ¶
type Edge struct {
Source string `json:"source"`
Target string `json:"target"`
Type EdgeType `json:"type"`
}
Edge represents a DAG edge (parent relationship)
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer for DAG-based chains
func (*Indexer) StoreVertex ¶
StoreVertex stores a vertex and broadcasts to subscribers
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller polls for new vertices
func NewPoller ¶
func NewPoller(idx *Indexer, sub *Subscriber) *Poller
type Stats ¶
type Stats struct {
TotalVertices int64 `json:"total_vertices"`
PendingVertices int64 `json:"pending_vertices"`
AcceptedVertices int64 `json:"accepted_vertices"`
TotalEdges int64 `json:"total_edges"`
ChainType ChainType `json:"chain_type"`
LastUpdated time.Time `json:"last_updated"`
}
Stats for DAG chain
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber handles WebSocket for live DAG streaming
func NewSubscriber ¶
func NewSubscriber(ct ChainType) *Subscriber
func (*Subscriber) BroadcastEdge ¶
func (s *Subscriber) BroadcastEdge(e Edge)
func (*Subscriber) BroadcastVertex ¶
func (s *Subscriber) BroadcastVertex(v *Vertex)
func (*Subscriber) ClientCount ¶
func (s *Subscriber) ClientCount() int
func (*Subscriber) HandleWebSocket ¶
func (s *Subscriber) HandleWebSocket(w http.ResponseWriter, r *http.Request)
func (*Subscriber) Run ¶
func (s *Subscriber) Run(ctx context.Context)
type Vertex ¶
type Vertex struct {
ID string `json:"id"`
Type string `json:"type"`
ParentIDs []string `json:"parentIds"` // Multiple parents (DAG)
Height uint64 `json:"height"`
Epoch uint32 `json:"epoch,omitempty"`
TxIDs []string `json:"txIds,omitempty"`
Timestamp time.Time `json:"timestamp"`
Status Status `json:"status"`
Data json.RawMessage `json:"data,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
QuasarCert json.RawMessage `json:"quasarCert,omitempty"` // Triple consensus cert (Q-Chain)
}
Vertex represents a DAG vertex (from luxfi/consensus) Multiple parents allowed (DAG structure)
Click to show internal directories.
Click to hide internal directories.