index

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	ConcurrentTransactions: 16,
	FlushInterval:          time.Second,
}

DefaultConfig is the default configuration for the DPS index.

Functions

func WithConcurrentTransactions

func WithConcurrentTransactions(concurrent uint) func(*Config)

WithConcurrentTransactions specifies the maximum concurrent transactions that a DPS index should have.

func WithFlushInterval added in v1.4.0

func WithFlushInterval(interval time.Duration) func(*Config)

WithFlushInterval sets a custom interval after which we will flush Badger transactions, to avoid long waits for DB updates in cases where there is not enough data to quickly fill them.

Types

type Config

type Config struct {
	ConcurrentTransactions uint
	FlushInterval          time.Duration
}

Config is the configuration of a DPS index.

type MetricsWriter added in v1.4.4

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

MetricsWriter wraps the writer and records metrics for the data it writes.

func NewMetricsWriter added in v1.4.4

func NewMetricsWriter(write *Writer) *MetricsWriter

NewMetricsWriter creates a counter that counts indexed elements and exposes this information as prometheus counters.

func (*MetricsWriter) Collections added in v1.4.4

func (w *MetricsWriter) Collections(height uint64, collections []*flow.LightCollection) error

func (*MetricsWriter) Commit added in v1.4.4

func (w *MetricsWriter) Commit(height uint64, commit flow.StateCommitment) error

func (*MetricsWriter) Events added in v1.4.4

func (w *MetricsWriter) Events(height uint64, events []flow.Event) error

func (*MetricsWriter) First added in v1.4.4

func (w *MetricsWriter) First(height uint64) error

func (*MetricsWriter) Guarantees added in v1.4.4

func (w *MetricsWriter) Guarantees(height uint64, guarantees []*flow.CollectionGuarantee) error

func (*MetricsWriter) Header added in v1.4.4

func (w *MetricsWriter) Header(height uint64, header *flow.Header) error

func (*MetricsWriter) Height added in v1.4.4

func (w *MetricsWriter) Height(blockID flow.Identifier, height uint64) error

func (*MetricsWriter) Last added in v1.4.4

func (w *MetricsWriter) Last(height uint64) error

func (*MetricsWriter) Payloads added in v1.4.4

func (w *MetricsWriter) Payloads(height uint64, paths []ledger.Path, payloads []*ledger.Payload) error

func (*MetricsWriter) Results added in v1.4.4

func (w *MetricsWriter) Results(results []*flow.TransactionResult) error

func (*MetricsWriter) Seals added in v1.4.4

func (w *MetricsWriter) Seals(height uint64, seals []*flow.Seal) error

func (*MetricsWriter) Transactions added in v1.4.4

func (w *MetricsWriter) Transactions(height uint64, transactions []*flow.TransactionBody) error

type Reader

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

Reader implements the `index.Reader` interface on top of the DPS server's Badger database index.

func NewReader

func NewReader(db *badger.DB, lib dps.ReadLibrary) *Reader

NewReader creates a new index reader, using the given database as the underlying state repository. It is recommended to provide a read-only Badger database.

func (*Reader) Collection added in v1.1.0

func (r *Reader) Collection(collID flow.Identifier) (*flow.LightCollection, error)

Collection returns the collection with the given ID.

func (*Reader) CollectionsByHeight added in v1.1.0

func (r *Reader) CollectionsByHeight(height uint64) ([]flow.Identifier, error)

CollectionsByHeight returns the collection IDs at the given height.

func (*Reader) Commit

func (r *Reader) Commit(height uint64) (flow.StateCommitment, error)

Commit returns the commitment of the execution state as it was after the execution of the finalized block at the given height.

func (*Reader) Events

func (r *Reader) Events(height uint64, types ...flow.EventType) ([]flow.Event, error)

Events returns the events of all transactions that were part of the finalized block at the given height. It can optionally filter them by event type; if no event types are given, all events are returned.

func (*Reader) First

func (r *Reader) First() (uint64, error)

First returns the height of the first finalized block that was indexed.

func (*Reader) Guarantee added in v1.1.0

func (r *Reader) Guarantee(collID flow.Identifier) (*flow.CollectionGuarantee, error)

Guarantee returns the guarantee with the given collection ID.

func (*Reader) Header

func (r *Reader) Header(height uint64) (*flow.Header, error)

Header returns the header for the finalized block at the given height.

func (*Reader) HeightForBlock

func (r *Reader) HeightForBlock(blockID flow.Identifier) (uint64, error)

HeightForBlock returns the height for the given block identifier.

func (*Reader) HeightForTransaction added in v1.1.0

func (r *Reader) HeightForTransaction(txID flow.Identifier) (uint64, error)

HeightForTransaction returns the height of the block within which the given transaction identifier is.

func (*Reader) Last

func (r *Reader) Last() (uint64, error)

Last returns the height of the last finalized block that was indexed.

func (*Reader) Result added in v1.1.0

func (r *Reader) Result(txID flow.Identifier) (*flow.TransactionResult, error)

Result returns the transaction result for the given transaction ID.

func (*Reader) Seal added in v1.1.0

func (r *Reader) Seal(sealID flow.Identifier) (*flow.Seal, error)

Seal returns the seal with the given ID.

func (*Reader) SealsByHeight added in v1.1.0

func (r *Reader) SealsByHeight(height uint64) ([]flow.Identifier, error)

SealsByHeight returns all of the seals that were part of the finalized block at the given height.

func (*Reader) Transaction

func (r *Reader) Transaction(txID flow.Identifier) (*flow.TransactionBody, error)

Transaction returns the transaction with the given ID.

func (*Reader) TransactionsByHeight

func (r *Reader) TransactionsByHeight(height uint64) ([]flow.Identifier, error)

TransactionsByHeight returns the transaction IDs within the block with the given ID.

func (*Reader) Values

func (r *Reader) Values(height uint64, paths []ledger.Path) ([]ledger.Value, error)

Values returns the Ledger values of the execution state at the given paths as they were after the execution of the finalized block at the given height. For compatibility with existing Flow execution node code, a path that is not found within the indexed execution state returns a nil value without error.

type Writer

type Writer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Writer implements the `index.Writer` interface to write indexing data to an underlying Badger database.

func NewWriter

func NewWriter(db *badger.DB, lib dps.WriteLibrary, options ...func(*Config)) *Writer

NewWriter creates a new index writer that writes new indexing data to the given Badger database.

func (*Writer) Close

func (w *Writer) Close() error

Close closes the writer and commits the pending transaction, if there is one.

func (*Writer) Collections

func (w *Writer) Collections(height uint64, collections []*flow.LightCollection) error

Collections indexes the collections at the given height.

func (*Writer) Commit

func (w *Writer) Commit(height uint64, commit flow.StateCommitment) error

Commit indexes the given commitment of the execution state as it was after the execution of the finalized block at the given height.

func (*Writer) Events

func (w *Writer) Events(height uint64, events []flow.Event) error

Events indexes the events, which should represent all events of the finalized block at the given height.

func (*Writer) First

func (w *Writer) First(height uint64) error

First indexes the height of the first finalized block.

func (*Writer) Guarantees added in v1.1.0

func (w *Writer) Guarantees(_ uint64, guarantees []*flow.CollectionGuarantee) error

Guarantees indexes the guarantees at the given height.

func (*Writer) Header

func (w *Writer) Header(height uint64, header *flow.Header) error

Header indexes the given header of a finalized block at the given height.

func (*Writer) Height

func (w *Writer) Height(blockID flow.Identifier, height uint64) error

Height indexes the height for the given block ID.

func (*Writer) Last

func (w *Writer) Last(height uint64) error

Last indexes the height of the last finalized block.

func (*Writer) Payloads

func (w *Writer) Payloads(height uint64, paths []ledger.Path, payloads []*ledger.Payload) error

Payloads indexes the given payloads, which should represent a trie update of the execution state contained within the finalized block at the given height.

func (*Writer) Results added in v1.1.0

func (w *Writer) Results(results []*flow.TransactionResult) error

Results indexes the transaction results at the given height.

func (*Writer) Seals added in v1.1.0

func (w *Writer) Seals(height uint64, seals []*flow.Seal) error

Seals indexes the seals, which should represent all seals in the finalized block at the given height.

func (*Writer) Transactions

func (w *Writer) Transactions(height uint64, transactions []*flow.TransactionBody) error

Transactions indexes the transactions at the given height.

Jump to

Keyboard shortcuts

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