db

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Overview

Package db holds everything SQLite-related for the bridge tracker: the sqliteRegistry adapter of domain.SupervisedRegistry and its migrations (see migrations/), mirroring how aggsender/db holds its own component's SQLite storage. It depends only on domain/types, never on the bridgetracker package itself, to avoid an import cycle (bridgetracker constructs this package's registry, see NewSQLiteRegistry's callers).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSQLiteActivityStore

func NewSQLiteActivityStore(
	dbPath string, scanner domain.ActivityBridgeScanner, claims domain.ActivityClaimChecker,
	supervised domain.SupervisedStore, logger aggkitcommon.Logger,
) (domain.ActivityRegistry, error)

NewSQLiteActivityStore returns a domain.ActivityRegistry backed by a SQLite database at dbPath, creating the file and running its migrations if it does not exist yet. dbPath may (and typically does) point at the same file bridgetracker/db.NewSQLiteRegistry uses — every migration in this package is always applied together, regardless of which store is constructed first (see migrations.RunMigrations). Idle eviction is entirely driven by whoever wires an ActivityEngine over the returned store (see ActivityEngineConfig.IdleTimeout, PruneIdle) — this constructor has no idleTimeout of its own to fall back to

func NewSQLiteRegistry

func NewSQLiteRegistry(
	dbPath string, maxEntries int, logger aggkitcommon.Logger, verifier BlockHashVerifier,
) (domain.SupervisedRegistry, error)

NewSQLiteRegistry returns a domain.SupervisedRegistry backed by a SQLite database at dbPath, creating the file and running its migrations if it does not exist yet. maxEntries <= 0 falls back to defaultMaxTrackedBridges, exactly like bridgetracker.NewMemoryRegistry. verifier may be nil, which skips reorg validation on reload entirely (see BlockHashVerifier)

Types

type BlockHashVerifier

type BlockHashVerifier interface {
	// CanonicalBlockHash returns the block hash currently canonical at blockNumber on networkID
	CanonicalBlockHash(ctx context.Context, networkID uint32, blockNumber uint64) (common.Hash, error)
}

BlockHashVerifier reports the current canonical hash at blockNumber on networkID, used by selectFreshRow to detect a persisted row whose origin block was since reorged out from under it — see its doc. A nil BlockHashVerifier (see NewSQLiteRegistry) skips this check entirely: the same trust-what's-on-disk behavior this adapter had before reorg validation existed, and the same exposure the in-memory adapter already has for the far shorter window it stays alive without a restart.

Directories

Path Synopsis
Package migrations holds the bridge tracker's own SQLite migrations (see bridgetracker's sqliteRegistry), following the same //go:embed + db.RunMigrations pattern as reorgdetector/migrations.
Package migrations holds the bridge tracker's own SQLite migrations (see bridgetracker's sqliteRegistry), following the same //go:embed + db.RunMigrations pattern as reorgdetector/migrations.

Jump to

Keyboard shortcuts

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