db

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PoolMigrationName is the name of the migration used by packr to pack the migration file
	PoolMigrationName = "zkevm-pool-db"
)

Variables

This section is empty.

Functions

func CheckMigrations

func CheckMigrations(cfg Config, name string) error

CheckMigrations runs migrate-up for the given config.

func NewSQLDB

func NewSQLDB(cfg Config) (*pgxpool.Pool, error)

NewSQLDB creates a new SQL DB

func RunMigrationsDown

func RunMigrationsDown(cfg Config, name string) error

RunMigrationsDown runs migrate-down for the given config.

func RunMigrationsUp

func RunMigrationsUp(cfg Config, name string) error

RunMigrationsUp runs migrate-up for the given config.

Types

type Config

type Config struct {
	// Database name
	Name string `mapstructure:"Name"`

	// Database User name
	User string `mapstructure:"User"`

	// Database Password of the user
	Password string `mapstructure:"Password"`

	// Host address of database
	Host string `mapstructure:"Host"`

	// Port Number of database
	Port string `mapstructure:"Port"`

	// EnableLog
	EnableLog bool `mapstructure:"EnableLog"`

	// MaxConns is the maximum number of connections in the pool.
	MaxConns int `mapstructure:"MaxConns"`
}

Config provide fields to configure the pool

type PoolDB

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

PoolDB represent a postgres pool database to store transactions

func NewPoolDB

func NewPoolDB(cfg Config) (*PoolDB, error)

NewPostgresPoolStorage creates and initializes an instance of PostgresPoolStorage

func (*PoolDB) AddL2Transaction

func (p *PoolDB) AddL2Transaction(ctx context.Context, tx *types.L2Transaction) (uint64, error)

AddTx adds a L2 transaction to the pool

func (*PoolDB) GetL2TransactionsByStatus

func (p *PoolDB) GetL2TransactionsByStatus(ctx context.Context, status string) ([]*types.L2Transaction, error)

func (*PoolDB) GetL2TransactionsToMonitor

func (p *PoolDB) GetL2TransactionsToMonitor(ctx context.Context) ([]*types.L2Transaction, error)

func (*PoolDB) GetL2TransactionsToResend

func (p *PoolDB) GetL2TransactionsToResend(ctx context.Context) ([]*types.L2Transaction, error)

func (*PoolDB) GetL2TransactionsToSend

func (p *PoolDB) GetL2TransactionsToSend(ctx context.Context) ([]*types.L2Transaction, error)

func (*PoolDB) UpdateL2TransactionStatus

func (p *PoolDB) UpdateL2TransactionStatus(ctx context.Context, id uint64, newStatus string, errorMsg string) error

Jump to

Keyboard shortcuts

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