db

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB allows to access the nodes public nodeDB

func CreateDBFromConfig

func CreateDBFromConfig(cfg *config.HostConfig, regMetrics gethmetrics.Registry, logger gethlog.Logger) (*DB, error)

func NewInMemoryDB

func NewInMemoryDB(regMetrics gethmetrics.Registry, logger gethlog.Logger) *DB

NewInMemoryDB returns a new instance of the Node DB

func NewLevelDBBackedDB

func NewLevelDBBackedDB(dbPath string, regMetrics gethmetrics.Registry, logger gethlog.Logger) (*DB, error)

NewLevelDBBackedDB creates a persistent DB for the host, if dbPath == "" it will generate a temp file

func (*DB) AddBatch

func (db *DB) AddBatch(batch *common.ExtBatch) error

AddBatch adds a batch and its header to the DB

func (*DB) AddBlock

func (db *DB) AddBlock(header *types.Header) error

AddBlock adds a types.Header to the known headers

func (*DB) AddRollupHeader

func (db *DB) AddRollupHeader(rollup *common.ExtRollup, block *common.L1Block) error

AddRollupHeader adds a rollup to the DB

func (*DB) GetBatch

func (db *DB) GetBatch(batchHash gethcommon.Hash) (*common.ExtBatch, error)

GetBatch returns the batch with the given hash.

func (*DB) GetBatchBySequenceNumber

func (db *DB) GetBatchBySequenceNumber(sequenceNumber *big.Int) (*common.ExtBatch, error)

GetBatchBySequenceNumber returns the batch with the given sequence number.

func (*DB) GetBatchHash

func (db *DB) GetBatchHash(number *big.Int) (*gethcommon.Hash, error)

GetBatchHash returns the hash of a batch given its number.

func (*DB) GetBatchHeader

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

GetBatchHeader returns the batch header given the hash.

func (*DB) GetBatchListing

func (db *DB) GetBatchListing(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. todo change this when the db changes - this is not super performant

func (*DB) GetBatchNumber

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

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

func (*DB) GetBatchTxs

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

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

func (*DB) GetBlockAtTip

func (db *DB) GetBlockAtTip() (*types.Header, error)

GetBlockAtTip returns the block at current Head or Tip

func (*DB) GetBlockByHash

func (db *DB) GetBlockByHash(hash gethcommon.Hash) (*types.Header, error)

GetBlockByHash returns the block header given the hash.

func (*DB) GetBlockByHeight

func (db *DB) GetBlockByHeight(height *big.Int) (*types.Header, error)

GetBlockByHeight returns the block header given the height

func (*DB) GetBlockListing

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

GetBlockListing returns latest L1 blocks given the pagination. For example, page 0, size 10 will return the latest 10 blocks.

func (*DB) GetHeadBatchHeader

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

GetHeadBatchHeader returns the header of the node's current head batch.

func (*DB) GetRollupHeader

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

GetRollupHeader returns the rollup with the given hash.

func (*DB) GetRollupHeaderByBlock

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

GetRollupHeaderByBlock returns the rollup for the given block

func (*DB) GetTipRollupHeader

func (db *DB) GetTipRollupHeader() (*common.RollupHeader, error)

GetTipRollupHeader returns the header of the node's current tip rollup.

func (*DB) GetTotalTransactions

func (db *DB) GetTotalTransactions() (*big.Int, error)

GetTotalTransactions returns the total number of batched transactions.

func (*DB) Stop

func (db *DB) Stop() error

Stop is especially important for graceful shutdown of LevelDB as it may flush data to disk that is currently in cache

type ObscuroLevelDB

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

ObscuroLevelDB is a very thin wrapper around a level DB database for compatibility with our internal interfaces In particular, it overrides the Get method to return the obscuro ErrNotFound

func (*ObscuroLevelDB) Close

func (o *ObscuroLevelDB) Close() error

func (*ObscuroLevelDB) Compact

func (o *ObscuroLevelDB) Compact(start []byte, limit []byte) error

func (*ObscuroLevelDB) Delete

func (o *ObscuroLevelDB) Delete(key []byte) error

func (*ObscuroLevelDB) Get

func (o *ObscuroLevelDB) Get(key []byte) ([]byte, error)

Get is overridden here to return our internal NotFound error

func (*ObscuroLevelDB) Has

func (o *ObscuroLevelDB) Has(key []byte) (bool, error)

func (*ObscuroLevelDB) NewBatch

func (o *ObscuroLevelDB) NewBatch() ethdb.Batch

func (*ObscuroLevelDB) NewBatchWithSize

func (o *ObscuroLevelDB) NewBatchWithSize(int) ethdb.Batch

func (*ObscuroLevelDB) NewIterator

func (o *ObscuroLevelDB) NewIterator(prefix []byte, start []byte) ethdb.Iterator

func (*ObscuroLevelDB) NewSnapshot

func (o *ObscuroLevelDB) NewSnapshot() (ethdb.Snapshot, error)

func (*ObscuroLevelDB) Put

func (o *ObscuroLevelDB) Put(key []byte, value []byte) error

func (*ObscuroLevelDB) Stat

func (o *ObscuroLevelDB) Stat(property string) (string, error)

Jump to

Keyboard shortcuts

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