daemon

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 18 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvOr

func EnvOr(key, fallback string) string

EnvOr returns the value of an env var, or fallback if unset.

func FindConfig

func FindConfig(dataDir string) string

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

func ListenAndServe(ctx context.Context, addr string, handler http.Handler)

ListenAndServe starts an HTTP server on addr with the given handler and blocks until ctx is done. Shutdown is graceful.

func MountHealth

func MountHealth(mux *http.ServeMux)

MountHealth registers /health and /healthz on mux.

func MountIndexerAPI

func MountIndexerAPI(ctx context.Context, cfg Config, mux *http.ServeMux)

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

func RunIndexers(ctx context.Context, cfg Config) *sync.WaitGroup

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

func LoadConfig(path string) (Config, error)

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.

Jump to

Keyboard shortcuts

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