node

package
v0.61.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const BackfillPhase = "metadata"

BackfillPhase is the phase name used for the historical metadata backfill checkpoint.

View Source
const DefaultBackfillBatchRows = 5000

DefaultBackfillBatchRows caps the accumulated metadata row count before a flush so dense eras do not hold oversized batches in memory.

View Source
const DefaultBackfillBatchSize = 100

DefaultBackfillBatchSize controls how many processed blocks are accumulated before deferred metadata rows are flushed.

Variables

This section is empty.

Functions

func CopyImmutableBlobsBounded added in v0.60.1

func CopyImmutableBlobsBounded(
	ctx context.Context,
	logger *slog.Logger,
	imm *immutable.ImmutableDb,
	c *chain.Chain,
	maxSlot uint64,
	onProgress func(LoadBlobsProgress),
) (int, uint64, error)

CopyImmutableBlobsBounded copies immutable blocks into the blob store from the current chain tip up to and including maxSlot, storing produced-UTxO offsets per block. maxSlot of 0 copies to the immutable tip. It reuses a caller-opened ImmutableDb and Chain so it can be invoked repeatedly during a download to overlap the copy with fetching (parallel fetch, sequenced processing). Returns the number of blocks copied and the highest slot copied.

Safe against chunks that arrive out of order: bounding by maxSlot (the last slot of a known-contiguous chunk prefix) stops the copy before it can reach a higher out-of-order chunk past a gap. Blocks above maxSlot are left for a later call with a higher bound.

func ImmutableUtxoOffsetsTipSlot added in v0.47.0

func ImmutableUtxoOffsetsTipSlot(
	db *database.Database,
) (uint64, bool, error)

ImmutableUtxoOffsetsTipSlot reports the latest slot for which the Mithril immutable-copy phase persisted produced-UTxO offset references. The second return value is false when no immutable copy has run (the sync-state key is unset); callers must treat that as "no skip threshold" and write offsets normally.

func Load added in v0.5.0

func Load(ctx context.Context, cfg *config.Config, logger *slog.Logger, immutableDir string) error

func LoadWithDB added in v0.22.0

func LoadWithDB(
	ctx context.Context,
	cfg *config.Config,
	logger *slog.Logger,
	immutableDir string,
	db *database.Database,
) error

LoadWithDB loads immutable DB blocks into the chain. If db is nil, a new database connection is opened (and closed on return).

func MarkImmutableUtxoOffsetsComplete added in v0.60.1

func MarkImmutableUtxoOffsetsComplete(
	db *database.Database,
	immutableTipSlot uint64,
) error

MarkImmutableUtxoOffsetsComplete records that produced-UTxO offset references are stored for every immutable block up to immutableTipSlot, so a later API backfill can skip re-writing them. It is idempotent. Callers that split the immutable copy (for example the pipelined download/copy) must call this after the copy completes, because the per-block copy stores the offsets but does not advance this marker on its own.

func RepairCriticalDeferredIndexes added in v0.51.0

func RepairCriticalDeferredIndexes(
	db *database.Database,
	logger *slog.Logger,
) error

RepairCriticalDeferredIndexes rebuilds the API/rollback-critical subset if a prior run left deferred indexes pending. It leaves the pending marker in place so RepairDeferredIndexes can finish the lazy remainder later.

func RepairDeferredIndexes added in v0.50.0

func RepairDeferredIndexes(
	db *database.Database,
	logger *slog.Logger,
) error

RepairDeferredIndexes rebuilds any deferred indexes that were recorded as pending by a prior interrupted run. It is safe to call when no rebuild is outstanding: BuildDeferredIndexes is itself idempotent and clears the marker.

func Run

func Run(cfg *config.Config, logger *slog.Logger) error

func RunPlannerStats added in v0.47.0

func RunPlannerStats(db *database.Database, logger *slog.Logger) error

RunPlannerStats collects query-planner statistics on the metadata store if it implements PlannerStatsUpdater. No-op for non-SQLite stores.

func WithBulkLoadPragmas added in v0.22.0

func WithBulkLoadPragmas(
	db *database.Database,
	logger *slog.Logger,
) func()

WithBulkLoadPragmas enables bulk-load optimizations on the metadata store if it implements BulkLoadOptimizer. The returned cleanup function restores normal pragmas and must be deferred by the caller.

Types

type Backfill added in v0.22.0

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

Backfill replays stored blocks to populate historical metadata. It is triggered automatically during Mithril sync when storageMode is "api".

func NewBackfill added in v0.22.0

func NewBackfill(
	db *database.Database,
	nodeCfg *cardano.CardanoNodeConfig,
	logger *slog.Logger,
) *Backfill

NewBackfill creates a new Backfill instance.

func (*Backfill) DisableNonceComputation added in v0.44.0

func (b *Backfill) DisableNonceComputation()

DisableNonceComputation skips historical block nonce reconstruction. Mithril imports already seed the ledger-state tip nonce needed for live sync; API metadata backfill does not need per-block historical nonce rows.

func (*Backfill) NeedsBackfill added in v0.22.0

func (b *Backfill) NeedsBackfill() (bool, error)

NeedsBackfill checks if there's an incomplete backfill checkpoint.

func (*Backfill) Run added in v0.22.0

func (b *Backfill) Run(ctx context.Context) error

Run executes the backfill. Blocks until complete or context cancelled. Safe to call multiple times; uses checkpoints for resume.

func (*Backfill) SetBatchSize added in v0.48.0

func (b *Backfill) SetBatchSize(size int) error

SetBatchSize overrides the number of processed blocks accumulated before deferred metadata rows are flushed.

func (*Backfill) SetImmutableUtxoOffsetsTipSlot added in v0.47.0

func (b *Backfill) SetImmutableUtxoOffsetsTipSlot(slot uint64)

SetImmutableUtxoOffsetsTipSlot informs the backfill that produced-UTxO offset references have already been persisted by the Mithril immutable-copy phase for every block at or below the given slot. The backfill will then elide the redundant blob writes for those blocks. Passing 0 explicitly disables the optimisation (every block will write offsets even when a matching sync-state marker exists). Calls take effect at Run() entry and suppress the auto-detect from the sync-state key. Has no effect if invoked after Run has started.

func (*Backfill) SetProgressFunc added in v0.50.0

func (b *Backfill) SetProgressFunc(onProgress func(BackfillProgress))

SetProgressFunc registers a callback for interval backfill counters.

type BackfillProgress added in v0.50.0

type BackfillProgress struct {
	Slot            uint64
	TipSlot         uint64
	ProcessedBlocks int
	ProcessedTxs    int
	BlocksPerSecond float64
	ProgressPercent float64
	Stats           dbtypes.BackfillHotPathStats
}

BackfillProgress is emitted with interval counters during metadata backfill.

type DeferredIndexRebuilder added in v0.51.0

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

DeferredIndexRebuilder owns the drop/rebuild pairing for a single bulk-load run. The critical subset can be rebuilt before API readiness; the full rebuild finishes the lazy maintenance work and clears the pending marker.

func WithDeferredIndexes added in v0.50.0

func WithDeferredIndexes(
	db *database.Database,
	logger *slog.Logger,
) *DeferredIndexRebuilder

WithDeferredIndexes drops the deferred-index manifest before bulk load and returns a rebuilder for the critical and full rebuild phases. Stores that do not implement metadata.DeferredIndexManager are silently skipped — the orchestrator behaves as if every index stayed in place.

BuildCritical must be called before the database is marked ready (i.e. before sync_status is cleared). BuildAll may run later as maintenance; it clears the pending marker once the full manifest exists.

func (*DeferredIndexRebuilder) BuildAll added in v0.51.0

func (r *DeferredIndexRebuilder) BuildAll() error

func (*DeferredIndexRebuilder) BuildCritical added in v0.51.0

func (r *DeferredIndexRebuilder) BuildCritical() error

type LoadBlobsOption added in v0.46.4

type LoadBlobsOption func(*loadBlobsOptions)

LoadBlobsOption customizes LoadBlobsWithDB behavior.

func WithLoadBlobsProgress added in v0.46.4

func WithLoadBlobsProgress(
	onProgress func(LoadBlobsProgress),
) LoadBlobsOption

WithLoadBlobsProgress registers a callback for blob-copy progress.

type LoadBlobsProgress added in v0.46.4

type LoadBlobsProgress struct {
	BlocksCopied    int
	CurrentSlot     uint64
	TipSlot         uint64
	BlocksPerSecond float64
	Percent         float64
}

LoadBlobsProgress reports ImmutableDB blob-copy progress.

type LoadBlobsResult added in v0.22.0

type LoadBlobsResult struct {
	BlocksCopied     int
	ImmutableTipSlot uint64
}

LoadBlobsResult contains the result of a blob-only ImmutableDB load.

func LoadBlobsWithDB added in v0.22.0

func LoadBlobsWithDB(
	ctx context.Context,
	cfg *config.Config,
	logger *slog.Logger,
	immutableDir string,
	db *database.Database,
	options ...LoadBlobsOption,
) (*LoadBlobsResult, error)

LoadBlobsWithDB copies blocks from an ImmutableDB directory into the blob store without starting the ledger processing pipeline. This is used after a Mithril snapshot import where the ledger state has already been loaded from the snapshot. Returns the number of blocks copied and the immutable tip slot so the caller can update the metadata tip to match.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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