pebble

package
v1.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MinLookupKeyLen defines the minimum length for a valid lookup key
	//
	// Lookup keys use the following format:
	//    [marker] [key] / [height]
	// Where:
	// - marker: 1 byte marking that this is a register key
	// - key: optional variable length field
	// - height: 8 bytes representing the block height (uint64)
	// - separator: '/' is used to separate variable length field
	//
	// Therefore the minimum key would be 2 bytes + # of bytes for height
	//    [marker]  / [height]
	MinLookupKeyLen = 2 + registers.HeightSuffixLen
)

Functions

func NewMVCCComparer added in v1.0.0

func NewMVCCComparer() *pebble.Comparer

Types

type Blocks

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

func NewBlocks

func NewBlocks(store *Storage, chainID flowGo.ChainID) *Blocks

func (*Blocks) GetByHeight

func (b *Blocks) GetByHeight(height uint64) (*models.Block, error)

func (*Blocks) GetByID

func (b *Blocks) GetByID(ID common.Hash) (*models.Block, error)

func (*Blocks) GetCadenceHeight

func (b *Blocks) GetCadenceHeight(evmHeight uint64) (uint64, error)

func (*Blocks) GetCadenceID added in v0.16.0

func (b *Blocks) GetCadenceID(evmHeight uint64) (flow.Identifier, error)

func (*Blocks) GetHeightByID added in v0.7.0

func (b *Blocks) GetHeightByID(ID common.Hash) (uint64, error)

func (*Blocks) InitHeights added in v0.2.0

func (b *Blocks) InitHeights(cadenceHeight uint64, cadenceID flow.Identifier, batch *pebble.Batch) error

InitHeights sets the Cadence height to zero as well as EVM heights. Used for empty database init.

func (*Blocks) LatestCadenceHeight

func (b *Blocks) LatestCadenceHeight() (uint64, error)

func (*Blocks) LatestEVMHeight

func (b *Blocks) LatestEVMHeight() (uint64, error)

func (*Blocks) SetLatestCadenceHeight added in v0.2.0

func (b *Blocks) SetLatestCadenceHeight(height uint64, batch *pebble.Batch) error

func (*Blocks) Store

func (b *Blocks) Store(
	cadenceHeight uint64,
	cadenceID flow.Identifier,
	block *models.Block,
	batch *pebble.Batch,
) error

type GetAtHeightFunc added in v1.0.0

type GetAtHeightFunc func(id flow.RegisterID, height uint64) (flow.RegisterValue, error)

type Receipts

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

func NewReceipts

func NewReceipts(store *Storage) *Receipts

func (*Receipts) BloomsForBlockRange

func (r *Receipts) BloomsForBlockRange(start, end uint64) ([]*models.BloomsHeight, error)

func (*Receipts) GetByBlockHeight

func (r *Receipts) GetByBlockHeight(height uint64) ([]*models.Receipt, error)

func (*Receipts) GetByTransactionID

func (r *Receipts) GetByTransactionID(ID common.Hash) (*models.Receipt, error)

func (*Receipts) Store

func (r *Receipts) Store(receipts []*models.Receipt, batch *pebble.Batch) error

Store receipt in the index.

Storing receipt will create multiple indexes, each receipt has a transaction ID, and a block height. We create following mappings: - receipt transaction ID => block height bytes - receipt block height => list of encoded receipts (1+ per block) - receipt block height => list of bloom filters (1+ per block)

type RegisterStorage added in v1.0.0

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

func NewRegisterStorage added in v1.0.0

func NewRegisterStorage(
	store *Storage,
	owner flow.Address,
) *RegisterStorage

NewRegisterStorage creates a new index instance at the provided height, all reads and writes of the registers will happen at that height. this is not concurrency safe.

The register store does verify that the owner supplied is the one that was used before, or that the heights are sequential. This should be done by the caller.

The RegisterStorage is modeled after `pebble.Registers` from `flow-go` but there are a few differences:

  1. The `flow-go` implementation creates its own independent batch when saving registers. The gateway needs to save the registers together with blocks and transaction so the batch is shared with that.
  2. The gateway does not need to store the owner address as all the registers are for the same owner.
  3. The gateway does not need pruning (yet) as the db is supposed to be much smaller.
  4. The owner and height checks are expected to be performed by the caller.

func (*RegisterStorage) Get added in v1.0.0

func (r *RegisterStorage) Get(id flow.RegisterID, height uint64) (value flow.RegisterValue, err error)

Get returns the register value for the given register ID at the given height. Get will check that the owner is the same as the one used to create the index.

func (*RegisterStorage) GetSnapshotAt added in v1.0.0

func (r *RegisterStorage) GetSnapshotAt(evmBlockHeight uint64) (types.BackendStorageSnapshot, error)

GetSnapshotAt returns a snapshot of the register index at the given block height. the snapshot has a cache. Nil values are cached.

func (*RegisterStorage) Store added in v1.0.0

func (r *RegisterStorage) Store(entries flow.RegisterEntries, height uint64, batch *pebble.Batch) error

Store stores the register entries for the given height to the given batch. The batch does need to be indexed.

Store will check that all the register entries are for the same owner.

type Storage

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

func New

func New(dir string, log zerolog.Logger) (*Storage, error)

New creates a new storage instance using the provided dir location as the storage directory.

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) NewBatch added in v0.22.0

func (s *Storage) NewBatch() *pebble.Batch

type StorageSnapshot added in v1.0.0

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

func NewStorageSnapshot added in v1.0.0

func NewStorageSnapshot(get GetAtHeightFunc, evmBlockHeight uint64) *StorageSnapshot

NewStorageSnapshot creates a new snapshot of the register index at the given block height. the snapshot has a cache. Nil values are cached. The snapshot is not concurrency-safe.

func (StorageSnapshot) GetValue added in v1.0.0

func (s StorageSnapshot) GetValue(owner []byte, key []byte) ([]byte, error)

GetValue returns the value for the given register ID at the snapshot block height. If the value is not found in the cache, it is fetched from the register index.

type Traces added in v0.16.0

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

func NewTraces added in v0.16.0

func NewTraces(store *Storage) *Traces

func (*Traces) GetTransaction added in v0.16.0

func (t *Traces) GetTransaction(ID common.Hash) (json.RawMessage, error)

func (*Traces) StoreTransaction added in v0.16.0

func (t *Traces) StoreTransaction(ID common.Hash, trace json.RawMessage, batch *pebble.Batch) error

type Transactions

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

func NewTransactions

func NewTransactions(store *Storage) *Transactions

func (*Transactions) Get

func (*Transactions) Store

func (t *Transactions) Store(tx models.Transaction, batch *pebble.Batch) error

Jump to

Keyboard shortcuts

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