Files
Zach Kelling 4e2a4e432e chore: remove local replace directives and update dependencies
- Update github.com/luxfi/keys v1.0.5 → v1.0.6
- Update github.com/luxfi/genesis v1.5.18 → v1.5.19
- Remove local replace directives for keys and genesis
- Use published package versions for reproducible builds
2026-01-03 07:05:17 -08:00

71 lines
1.3 KiB
Go

// Copyright (C) 2025, Lux Industries Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
package orchestrator
import (
"sync"
"time"
)
// Indexer provides cross-engine blockchain indexing
type Indexer struct {
mu sync.RWMutex
data map[string]*IndexData
}
// IndexData contains indexed blockchain data
type IndexData struct {
Engine string
LastUpdate time.Time
BlockHeight uint64
Transactions uint64
Accounts uint64
Extra map[string]interface{}
}
// NewIndexer creates a new indexer
func NewIndexer() *Indexer {
return &Indexer{
data: make(map[string]*IndexData),
}
}
// Update updates index data for an engine
func (i *Indexer) Update(engine string, data *IndexData) {
i.mu.Lock()
defer i.mu.Unlock()
data.Engine = engine
data.LastUpdate = time.Now()
i.data[engine] = data
}
// Get retrieves index data for an engine
func (i *Indexer) Get(engine string) *IndexData {
i.mu.RLock()
defer i.mu.RUnlock()
return i.data[engine]
}
// GetAll retrieves all index data
func (i *Indexer) GetAll() map[string]*IndexData {
i.mu.RLock()
defer i.mu.RUnlock()
result := make(map[string]*IndexData)
for k, v := range i.data {
result[k] = v
}
return result
}
// Clear clears index data for an engine
func (i *Indexer) Clear(engine string) {
i.mu.Lock()
defer i.mu.Unlock()
delete(i.data, engine)
}