db

package
v0.3.2-RC9 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSQLDB

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

NewSQLDB creates a new SQL DB

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 is the configuration for the database

type StateDB

type StateDB struct {
	*pgxpool.Pool
}

StateDB implements the StateDB interface

func NewStateDB

func NewStateDB(db *pgxpool.Pool) *StateDB

NewStateDB creates a new StateDB

func (*StateDB) GetGenesisBlock

func (db *StateDB) GetGenesisBlock(ctx context.Context) (*state.DSL2Block, error)

GetGenesisBlock returns the genesis block

func (*StateDB) GetL2Blocks

func (db *StateDB) GetL2Blocks(ctx context.Context, limit, offset uint64) ([]*state.DSL2Block, error)

GetL2Blocks returns the L2 blocks

func (*StateDB) GetL2Transactions

func (db *StateDB) GetL2Transactions(ctx context.Context, minL2Block, maxL2Block uint64) ([]*state.DSL2Transaction, error)

GetL2Transactions returns the L2 transactions

Jump to

Keyboard shortcuts

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