storage

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	// SetLatestHeight saves the latest block height to the storage
	SetLatestHeight(uint64) error
	// SetBlock saves the block to the permanent storage
	SetBlock(block *types.Block) error
	// SetTx saves the transaction to the permanent storage
	SetTx(tx *types.TxResult) error

	// Commit stores all the provided info on the storage and make
	// it available for other storage readers
	Commit() error

	// Rollback rollbacks the operation not persisting the provided changes
	Rollback() error
}

type Iterator

type Iterator[T any] interface {
	io.Closer
	Next() bool
	Error() error
	Value() (T, error)
}

type Pebble

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

Pebble is the instance of an embedded storage

func NewPebble

func NewPebble(path string) (*Pebble, error)

NewPebble creates a new storage instance at the given path

func (*Pebble) BlockIterator

func (s *Pebble) BlockIterator(fromBlockNum, toBlockNum uint64) (Iterator[*types.Block], error)

func (*Pebble) Close

func (s *Pebble) Close() error

func (*Pebble) GetBlock

func (s *Pebble) GetBlock(blockNum uint64) (*types.Block, error)

GetBlock fetches the specified block from storage, if any

func (*Pebble) GetLatestHeight

func (s *Pebble) GetLatestHeight() (uint64, error)

GetLatestHeight fetches the latest saved height from storage

func (*Pebble) GetTx

func (s *Pebble) GetTx(blockNum uint64, index uint32) (*types.TxResult, error)

GetTx fetches the specified tx result from storage, if any

func (*Pebble) GetTxByHash

func (s *Pebble) GetTxByHash(txHash string) (*types.TxResult, error)

func (*Pebble) TxIterator

func (s *Pebble) TxIterator(
	fromBlockNum,
	toBlockNum uint64,
	fromTxIndex,
	toTxIndex uint32,
) (Iterator[*types.TxResult], error)

func (*Pebble) WriteBatch

func (s *Pebble) WriteBatch() Batch

type PebbleBatch

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

func (*PebbleBatch) Commit

func (b *PebbleBatch) Commit() error

func (*PebbleBatch) Rollback

func (b *PebbleBatch) Rollback() error

Rollback closes the pebble batch without persisting any data. error output is always nil.

func (*PebbleBatch) SetBlock

func (b *PebbleBatch) SetBlock(block *types.Block) error

func (*PebbleBatch) SetLatestHeight

func (b *PebbleBatch) SetLatestHeight(h uint64) error

func (*PebbleBatch) SetTx

func (b *PebbleBatch) SetTx(tx *types.TxResult) error

type PebbleBlockIter

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

func (*PebbleBlockIter) Close

func (pi *PebbleBlockIter) Close() error

func (*PebbleBlockIter) Error

func (pi *PebbleBlockIter) Error() error

func (*PebbleBlockIter) Next

func (pi *PebbleBlockIter) Next() bool

func (*PebbleBlockIter) Value

func (pi *PebbleBlockIter) Value() (*types.Block, error)

type PebbleTxIter

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

func (*PebbleTxIter) Close

func (pi *PebbleTxIter) Close() error

func (*PebbleTxIter) Error

func (pi *PebbleTxIter) Error() error

func (*PebbleTxIter) Next

func (pi *PebbleTxIter) Next() bool

func (*PebbleTxIter) Value

func (pi *PebbleTxIter) Value() (*types.TxResult, error)

type Reader

type Reader interface {
	io.Closer
	// GetLatestHeight returns the latest block height from the storage
	GetLatestHeight() (uint64, error)

	// GetBlock fetches the block by its number
	GetBlock(uint64) (*types.Block, error)

	// GetTx fetches the tx using the block height and the transaction index
	GetTx(blockNum uint64, index uint32) (*types.TxResult, error)

	// GetTxByHash fetches the tx using the transaction hash
	GetTxByHash(txHash string) (*types.TxResult, error)

	// BlockIterator iterates over Blocks, limiting the results to be between the provided block numbers
	BlockIterator(fromBlockNum, toBlockNum uint64) (Iterator[*types.Block], error)

	// TxIterator iterates over transactions, limiting the results to be between the provided block numbers
	// and transaction indexes
	TxIterator(fromBlockNum, toBlockNum uint64, fromTxIndex, toTxIndex uint32) (Iterator[*types.TxResult], error)
}

Reader defines the transaction storage interface for read methods

type Storage

type Storage interface {
	Reader
	Writer
}

Storage represents the permanent storage abstraction for reading and writing operations

type Writer

type Writer interface {
	io.Closer
	// WriteBatch provides a batch intended to do a write action that
	// can be cancelled or committed all at the same time
	WriteBatch() Batch
}

Writer defines the transaction storage interface for write methods

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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