db

package
v0.0.2-alpha Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// StreamTypeSequencer represents a Sequencer stream
	StreamTypeSequencer datastreamer.StreamType = 1
	// EntryTypeL2Block represents a L2 block
	EntryTypeL2Block datastreamer.EntryType = 1
	// EntryTypeL2Tx represents a L2 transaction
	EntryTypeL2Tx datastreamer.EntryType = 2
)

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"`
}

type L2Block

type L2Block struct {
	BatchNumber    uint64
	L2BlockNumber  uint64
	Timestamp      time.Time
	GlobalExitRoot common.Hash
	Coinbase       common.Address
}

L2Block represents a L2 block

func (L2Block) Encode

func (b L2Block) Encode() []byte

Encode returns the encoded L2Block as a byte slice

type L2Transaction

type L2Transaction struct {
	BatchNumber                 uint64
	EffectiveGasPricePercentage uint8
	IsValid                     uint8
	EncodedLength               uint32
	Encoded                     []byte
}

L2Transaction represents a L2 transaction

func DecodeL2Transaction

func DecodeL2Transaction(data []byte) L2Transaction

DecodeL2Transaction decodes a byte slice into a L2Transaction

func (L2Transaction) Encode

func (l L2Transaction) Encode() []byte

Encode returns the encoded L2Transaction as a byte slice

type StateDB

type StateDB struct {
	*pgxpool.Pool
}

StateDB implements the StateDB interface

func NewStateDB

func NewStateDB(db *pgxpool.Pool) *StateDB

NewPostgresStorage creates a new StateDB

func (*StateDB) GetL2Blocks

func (db *StateDB) GetL2Blocks(ctx context.Context, limit, offset uint) ([]*L2Block, error)

func (*StateDB) GetL2Transactions

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

Jump to

Keyboard shortcuts

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