Documentation
¶
Overview ¶
Package db provides a lightweight GORM-based SQLite wrapper for persisting state required by the Push Universal Validator (UV), with per-chain database isolation.
Package db provides a lightweight GORM-based SQLite wrapper for persisting state required by the Push Universal Validator (UV), such as block tracking, processed cross-chain messages, and transaction receipts.
Index ¶
Constants ¶
const (
// InMemorySQLiteDSN is a special DSN to create an ephemeral in-memory SQLite database.
InMemorySQLiteDSN = ":memory:"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainDBManager ¶
type ChainDBManager struct {
// contains filtered or unexported fields
}
ChainDBManager manages per-chain database instances for traffic isolation
func NewChainDBManager ¶
NewChainDBManager creates a new manager for per-chain databases
func NewInMemoryChainDBManager ¶
func NewInMemoryChainDBManager(logger zerolog.Logger, cfg *config.Config) *ChainDBManager
NewInMemoryChainDBManager creates a manager with in-memory databases (for testing)
func (*ChainDBManager) CloseAll ¶
func (m *ChainDBManager) CloseAll() error
CloseAll closes all database connections
func (*ChainDBManager) CloseChainDB ¶
func (m *ChainDBManager) CloseChainDB(chainID string) error
CloseChainDB closes and removes a specific chain's database from the manager
func (*ChainDBManager) GetAllDatabases ¶
func (m *ChainDBManager) GetAllDatabases() map[string]*DB
GetAllDatabases returns all active database instances
func (*ChainDBManager) GetChainDB ¶
func (m *ChainDBManager) GetChainDB(chainID string) (*DB, error)
GetChainDB returns a database instance for a specific chain Creates the database lazily if it doesn't exist
func (*ChainDBManager) GetDatabaseStats ¶
func (m *ChainDBManager) GetDatabaseStats() map[string]interface{}
GetDatabaseStats returns statistics about managed databases
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a GORM client and provides simplified DB lifecycle management.
func OpenFileDB ¶
OpenFileDB opens (or creates) a file-backed SQLite database located in the given directory. If `migrateSchema` is true, all defined schema models are automatically migrated.
func OpenInMemoryDB ¶
OpenInMemoryDB opens a non-persistent SQLite database in memory. This is useful for testing or ephemeral state.
func (*DB) DeleteOldConfirmedTransactions ¶
DeleteOldConfirmedTransactions removes confirmed gateway transactions older than the specified retention period. Only transactions with status "confirmed" that were last updated before the cutoff time are deleted. Returns the number of deleted records and any error encountered.
func (*DB) SetupDBForTesting ¶
SetupDBForTesting sets the internal GORM client for testing purposes. This should only be used in test files.
type PerChainTransactionCleaner ¶
type PerChainTransactionCleaner struct {
// contains filtered or unexported fields
}
PerChainTransactionCleaner handles periodic cleanup of old confirmed transactions with per-chain configuration
func NewPerChainTransactionCleaner ¶
func NewPerChainTransactionCleaner( dbManager *ChainDBManager, cfg *config.Config, logger zerolog.Logger, ) *PerChainTransactionCleaner
NewPerChainTransactionCleaner creates a new per-chain transaction cleaner
func (*PerChainTransactionCleaner) GetCleanerStatus ¶
func (tc *PerChainTransactionCleaner) GetCleanerStatus() map[string]struct { CleanupInterval time.Duration RetentionPeriod time.Duration }
GetCleanerStatus returns the status of all chain cleaners
func (*PerChainTransactionCleaner) Start ¶
func (tc *PerChainTransactionCleaner) Start(ctx context.Context) error
Start begins the per-chain cleanup process
func (*PerChainTransactionCleaner) Stop ¶
func (tc *PerChainTransactionCleaner) Stop()
Stop gracefully stops all chain cleaners
func (*PerChainTransactionCleaner) UpdateChainConfig ¶
func (tc *PerChainTransactionCleaner) UpdateChainConfig(chainID string)
UpdateChainConfig updates the configuration for a specific chain's cleaner