hostdb

package
v0.24.4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: AGPL-3.0 Imports: 13 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.PublicBatch, 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 GetBatchHeaderByHeight added in v0.24.1

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

GetBatchHeaderByHeight returns the batch header given the height

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 GetBatchTransactions added in v0.24.1

func GetBatchTransactions(db HostDB, batchHash gethcommon.Hash) (*common.TransactionListingResponse, error)

GetBatchTransactions returns the TransactionListingResponse for a given batch hash

func GetBatchTxHashes added in v0.24.1

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

GetBatchTxHashes 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 HostDB) (*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 HostDB) (*common.BatchHeader, error)

GetHeadBatchHeader returns the latest batch header.

func GetLatestBatch

func GetLatestBatch(db HostDB) (*common.BatchHeader, error)

GetLatestBatch returns the head batch header

func GetLatestRollup

func GetLatestRollup(db HostDB) (*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 GetRollupBatches added in v0.24.1

func GetRollupBatches(db HostDB, rollupHash gethcommon.Hash) (*common.BatchListingResponse, error)

func GetRollupByHash added in v0.24.1

func GetRollupByHash(db HostDB, rollupHash gethcommon.Hash) (*common.PublicRollup, error)

func GetRollupBySeqNo added in v0.24.1

func GetRollupBySeqNo(db HostDB, seqNo uint64) (*common.PublicRollup, error)

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 HostDB) (*big.Int, error)

GetTotalTxCount returns value from the transaction count table

func GetTotalTxsQuery added in v0.24.1

func GetTotalTxsQuery(db HostDB) (*big.Int, error)

GetTotalTxsQuery returns the count of the transactions table

func GetTransaction added in v0.24.1

func GetTransaction(db HostDB, hash gethcommon.Hash) (*common.PublicTransaction, error)

GetTransaction returns a transaction given its hash

func GetTransactionListing added in v0.24.1

func GetTransactionListing(db HostDB, pagination *common.QueryPagination) (*common.TransactionListingResponse, error)

GetTransactionListing returns a paginated list of transactions in descending order

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
	Pagination         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