hostdb

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBatch

func AddBatch(dbtx *dbTransaction, statements *SQLStatements, batch *common.ExtBatch) error

AddBatch adds a batch and its header to the DB

func AddBlock

func AddBlock(dbtx *dbTransaction, statements *SQLStatements, b *types.Header, rollupHash common.L2RollupHash) error

AddBlock stores a block header with the given rollupHash it contains in the host DB

func AddRollup

func AddRollup(dbtx *dbTransaction, statements *SQLStatements, rollup *common.ExtRollup, metadata *common.PublicRollupMetadata, block *common.L1Block) error

AddRollup adds a rollup to the DB

func GetBatchByHash

func GetBatchByHash(db HostDB, hash common.L2BatchHash) (*common.ExtBatch, error)

GetBatchByHash returns the batch with the given hash.

func GetBatchByHeight

func GetBatchByHeight(db HostDB, height *big.Int) (*common.BatchHeader, error)

GetBatchByHeight returns the batch header given the height

func GetBatchBySequenceNumber

func GetBatchBySequenceNumber(db HostDB, seqNo uint64) (*common.ExtBatch, error)

GetBatchBySequenceNumber returns the ext batch for a given sequence number.

func GetBatchByTx

func GetBatchByTx(db HostDB, txHash gethcommon.Hash) (*common.ExtBatch, error)

GetBatchByTx returns the batch with the given hash.

func GetBatchHashByNumber

func GetBatchHashByNumber(db HostDB, number *big.Int) (*gethcommon.Hash, error)

GetBatchHashByNumber returns the hash of a batch given its number.

func GetBatchHeader

func GetBatchHeader(db HostDB, hash gethcommon.Hash) (*common.BatchHeader, error)

GetBatchHeader returns the batch header given the hash.

func GetBatchListing

func GetBatchListing(db HostDB, pagination *common.QueryPagination) (*common.BatchListingResponse, error)

GetBatchListing returns latest batches given a pagination. For example, page 0, size 10 will return the latest 10 batches.

func GetBatchListingDeprecated

func GetBatchListingDeprecated(db HostDB, pagination *common.QueryPagination) (*common.BatchListingResponseDeprecated, error)

GetBatchListingDeprecated returns latest batches given a pagination. For example, page 0, size 10 will return the latest 10 batches.

func GetBatchNumber

func GetBatchNumber(db HostDB, txHash gethcommon.Hash) (*big.Int, error)

GetBatchNumber returns the height of the batch containing the given transaction hash.

func GetBatchTxs

func GetBatchTxs(db HostDB, batchHash gethcommon.Hash) ([]gethcommon.Hash, error)

GetBatchTxs returns the transaction hashes of the batch with the given hash.

func GetBlockListing

func GetBlockListing(db HostDB, pagination *common.QueryPagination) (*common.BlockListingResponse, error)

GetBlockListing returns a paginated list of blocks in descending order against the order they were added

func GetCurrentHeadBatch

func GetCurrentHeadBatch(db *sql.DB) (*common.PublicBatch, error)

GetCurrentHeadBatch retrieves the current head batch with the largest sequence number (or height).

func GetExtRollup

func GetExtRollup(db HostDB, hash gethcommon.Hash) (*common.ExtRollup, error)

func GetHeadBatchHeader

func GetHeadBatchHeader(db *sql.DB) (*common.BatchHeader, error)

GetHeadBatchHeader returns the latest batch header.

func GetLatestBatch

func GetLatestBatch(db *sql.DB) (*common.BatchHeader, error)

GetLatestBatch returns the head batch header

func GetLatestRollup

func GetLatestRollup(db *sql.DB) (*common.RollupHeader, error)

GetLatestRollup returns the latest rollup ordered by timestamp

func GetPublicBatch

func GetPublicBatch(db HostDB, hash common.L2BatchHash) (*common.PublicBatch, error)

GetPublicBatch returns the batch with the given hash.

func GetPublicBatchBySequenceNumber

func GetPublicBatchBySequenceNumber(db HostDB, seqNo uint64) (*common.PublicBatch, error)

GetPublicBatchBySequenceNumber returns the batch with the given sequence number.

func GetRollupHeader

func GetRollupHeader(db HostDB, hash gethcommon.Hash) (*common.RollupHeader, error)

GetRollupHeader returns the rollup with the given hash.

func GetRollupHeaderByBlock

func GetRollupHeaderByBlock(db HostDB, blockHash gethcommon.Hash) (*common.RollupHeader, error)

GetRollupHeaderByBlock returns the rollup for the given block

func GetRollupListing

func GetRollupListing(db HostDB, pagination *common.QueryPagination) (*common.RollupListingResponse, error)

GetRollupListing returns latest rollups given a pagination. For example, offset 1, size 10 will return the latest 11-20 rollups.

func GetTotalTxCount

func GetTotalTxCount(db *sql.DB) (*big.Int, error)

GetTotalTxCount returns the total number of batched transactions.

func GetTxsBySequenceNumber

func GetTxsBySequenceNumber(db HostDB, seqNo uint64) ([]common.TxHash, error)

GetTxsBySequenceNumber returns the transaction hashes with sequence number.

Types

type HostDB

type HostDB interface {
	GetSQLDB() *sql.DB
	NewDBTransaction() (*dbTransaction, error)
	GetSQLStatement() *SQLStatements
}

func NewHostDB

func NewHostDB(db *sql.DB, statements *SQLStatements) (HostDB, error)

type SQLStatements

type SQLStatements struct {
	InsertBatch        string
	InsertTransactions string
	InsertTxCount      string
	InsertRollup       string
	InsertBlock        string
	SelectRollups      string
	SelectBlocks       string
	Placeholder        string
}

SQLStatements struct holds SQL statements for a specific database type

func PostgresSQLStatements

func PostgresSQLStatements() *SQLStatements

func SQLiteSQLStatements

func SQLiteSQLStatements() *SQLStatements

Jump to

Keyboard shortcuts

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