Documentation
¶
Overview ¶
Package daemon is the chain-indexer bootstrap: it owns the per-chain indexers and the /v1/indexer/* HTTP API. The standalone indexerd binary (cmd/indexerd) is the only consumer in this repo. The unified luxfi/explorer binary imports it directly to compose indexer + graph + frontend into a single Go binary.
Index ¶
- func EnvOr(key, fallback string) string
- func FindConfig(dataDir string) string
- func HomeDir() string
- func ListenAndServe(ctx context.Context, addr string, handler http.Handler)
- func MountHealth(mux *http.ServeMux)
- func MountIndexerAPI(ctx context.Context, cfg Config, mux *http.ServeMux)
- func RunIndexers(ctx context.Context, cfg Config) *sync.WaitGroup
- type ChainConfig
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindConfig ¶
FindConfig returns the first existing path among a default search list, or "" if none are found. Callers may pass an explicit path to skip the search.
func HomeDir ¶
func HomeDir() string
HomeDir returns the current user's home directory, or "" if unknown.
func ListenAndServe ¶
ListenAndServe starts an HTTP server on addr with the given handler and blocks until ctx is done. Shutdown is graceful.
func MountHealth ¶
MountHealth registers /health and /healthz on mux.
func MountIndexerAPI ¶
MountIndexerAPI mounts /v1/indexer/* HTTP handlers for every enabled chain. It blocks until every chain's per-chain SQLite is ready (DB file exists and, for EVM chains, the evm_blocks table is created). Concurrent — each chain is mounted in its own goroutine. Returns when all are mounted or ctx is done.
Routes:
- /v1/indexer/* (default chain)
- /v1/indexer/{slug}/* (every chain, including the default chain alias)
- /v1/explorer/{slug}/* (legacy alias for non-default chains)
func RunIndexers ¶
RunIndexers spawns one chain-indexer goroutine per enabled chain in cfg. Each chain owns an isolated SQLite + ZapDB store rooted at {DataDir}/{slug}/. Returns a WaitGroup the caller can wait on for shutdown.
SQLite WAL is replicated to S3 when REPLICATE_S3_ENDPOINT is set.
Types ¶
type ChainConfig ¶
type ChainConfig struct {
Slug string `yaml:"slug"` // URL-safe identifier (e.g., "cchain")
Name string `yaml:"name"` // Display name
ChainID int64 `yaml:"chain_id"` // EVM chain ID (0 for non-EVM)
Type string `yaml:"type"` // evm, dag, linear, solana, bitcoin, cosmos
RPC string `yaml:"rpc"` // RPC endpoint
WS string `yaml:"ws"` // WebSocket endpoint (optional)
CoinSymbol string `yaml:"coin"` // Native coin symbol
Enabled bool `yaml:"enabled"` // Enable indexing
Default bool `yaml:"default"` // Default chain for /v1/indexer/* (no slug prefix)
}
ChainConfig defines a single chain to index.
type Config ¶
type Config struct {
DataDir string `yaml:"data_dir"`
HTTPAddr string `yaml:"http_addr"`
Chains []ChainConfig `yaml:"chains"`
}
Config is the top-level chain-indexer configuration. Extra YAML fields (frontend brand, graph schemas, etc.) are accepted and ignored — the unified luxfi/explorer binary owns those concerns.
func LoadConfig ¶
LoadConfig reads, parses and validates a YAML config from disk.
func (Config) EnabledChains ¶
func (c Config) EnabledChains() []ChainConfig
EnabledChains returns only the chains with Enabled=true.