badger

package
v0.14.0-fixing-sealing... Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: AGPL-3.0 Imports: 14 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitAll added in v0.12.0

func InitAll(metrics module.CacheMetrics, db *badger.DB) *storage.All

Types

type Blocks

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

Blocks implements a simple block storage around a badger DB.

func NewBlocks

func NewBlocks(db *badger.DB, headers *Headers, payloads *Payloads) *Blocks

NewBlocks ...

func (*Blocks) ByCollectionID

func (b *Blocks) ByCollectionID(collID flow.Identifier) (*flow.Block, error)

ByCollectionID ...

func (*Blocks) ByHeight

func (b *Blocks) ByHeight(height uint64) (*flow.Block, error)

ByHeight ...

func (*Blocks) ByID

func (b *Blocks) ByID(blockID flow.Identifier) (*flow.Block, error)

ByID ...

func (*Blocks) GetLastFullBlockHeight

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

GetLastFullBlockHeight ...

func (*Blocks) IndexBlockForCollections

func (b *Blocks) IndexBlockForCollections(blockID flow.Identifier, collIDs []flow.Identifier) error

IndexBlockForCollections ...

func (*Blocks) Store

func (b *Blocks) Store(block *flow.Block) error

Store ...

func (*Blocks) StoreTx

func (b *Blocks) StoreTx(block *flow.Block) func(*badger.Txn) error

StoreTx ...

func (*Blocks) UpdateLastFullBlockHeight

func (b *Blocks) UpdateLastFullBlockHeight(height uint64) error

UpdateLastFullBlockHeight upsert (update or insert) the last full block height

type Cache

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

func (*Cache) Get

func (c *Cache) Get(key interface{}) func(*badger.Txn) (interface{}, error)

Get will try to retrieve the resource from cache first, and then from the injected

func (*Cache) Put

func (c *Cache) Put(key interface{}, resource interface{}) func(*badger.Txn) error

Put will add an resource to the cache with the given ID.

type ChunkDataPacks

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

func NewChunkDataPacks

func NewChunkDataPacks(db *badger.DB) *ChunkDataPacks

func (*ChunkDataPacks) ByChunkID

func (ch *ChunkDataPacks) ByChunkID(chunkID flow.Identifier) (*flow.ChunkDataPack, error)

func (*ChunkDataPacks) Remove

func (ch *ChunkDataPacks) Remove(chunkID flow.Identifier) error

func (*ChunkDataPacks) Store

func (ch *ChunkDataPacks) Store(c *flow.ChunkDataPack) error

type Cleaner

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

func NewCleaner

func NewCleaner(log zerolog.Logger, db *badger.DB, metrics module.CleanerMetrics, frequency int) *Cleaner

NewCleaner returns a cleaner that runs the badger value log garbage collection once every `frequency` calls if a frequency of zero is passed in, we will not run the GC at all

func (*Cleaner) RunGC

func (c *Cleaner) RunGC()

type ClusterBlocks

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

ClusterBlocks implements a simple block storage around a badger DB.

func NewClusterBlocks

func NewClusterBlocks(db *badger.DB, chainID flow.ChainID, headers *Headers, payloads *ClusterPayloads) *ClusterBlocks

func (*ClusterBlocks) ByHeight

func (b *ClusterBlocks) ByHeight(height uint64) (*cluster.Block, error)

func (*ClusterBlocks) ByID

func (b *ClusterBlocks) ByID(blockID flow.Identifier) (*cluster.Block, error)

func (*ClusterBlocks) Store

func (b *ClusterBlocks) Store(block *cluster.Block) error

type ClusterPayloads

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

ClusterPayloads implements storage of block payloads for collection node cluster consensus.

func NewClusterPayloads

func NewClusterPayloads(cacheMetrics module.CacheMetrics, db *badger.DB) *ClusterPayloads

func (*ClusterPayloads) ByBlockID

func (cp *ClusterPayloads) ByBlockID(blockID flow.Identifier) (*cluster.Payload, error)

func (*ClusterPayloads) Store

func (cp *ClusterPayloads) Store(blockID flow.Identifier, payload *cluster.Payload) error

type Collections

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

func NewCollections

func NewCollections(db *badger.DB, transactions *Transactions) *Collections

func (*Collections) ByID

func (c *Collections) ByID(colID flow.Identifier) (*flow.Collection, error)

func (*Collections) LightByID

func (c *Collections) LightByID(colID flow.Identifier) (*flow.LightCollection, error)

func (*Collections) LightByTransactionID

func (c *Collections) LightByTransactionID(txID flow.Identifier) (*flow.LightCollection, error)

func (*Collections) Remove

func (c *Collections) Remove(colID flow.Identifier) error

func (*Collections) Store

func (c *Collections) Store(collection *flow.Collection) error

func (*Collections) StoreLight

func (c *Collections) StoreLight(collection *flow.LightCollection) error

func (*Collections) StoreLightAndIndexByTransaction

func (c *Collections) StoreLightAndIndexByTransaction(collection *flow.LightCollection) error

type Commits

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

func NewCommits

func NewCommits(collector module.CacheMetrics, db *badger.DB) *Commits

func (*Commits) ByBlockID

func (c *Commits) ByBlockID(blockID flow.Identifier) (flow.StateCommitment, error)

func (*Commits) Store

func (c *Commits) Store(blockID flow.Identifier, commit flow.StateCommitment) error

type EpochCommits

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

func NewEpochCommits

func NewEpochCommits(collector module.CacheMetrics, db *badger.DB) *EpochCommits

func (*EpochCommits) ByID

func (ec *EpochCommits) ByID(commitID flow.Identifier) (*flow.EpochCommit, error)

func (*EpochCommits) Store

func (ec *EpochCommits) Store(commit *flow.EpochCommit) error

TODO: can we remove this method? Its not contained in the interface.

func (*EpochCommits) StoreTx

func (ec *EpochCommits) StoreTx(commit *flow.EpochCommit) func(tx *badger.Txn) error

type EpochSetups

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

func NewEpochSetups

func NewEpochSetups(collector module.CacheMetrics, db *badger.DB) *EpochSetups

func (*EpochSetups) ByID

func (es *EpochSetups) ByID(setupID flow.Identifier) (*flow.EpochSetup, error)

func (*EpochSetups) StoreTx

func (es *EpochSetups) StoreTx(setup *flow.EpochSetup) func(tx *badger.Txn) error

type EpochStatuses

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

func NewEpochStatuses

func NewEpochStatuses(collector module.CacheMetrics, db *badger.DB) *EpochStatuses

NewEpochStatuses ...

func (*EpochStatuses) ByBlockID

func (es *EpochStatuses) ByBlockID(blockID flow.Identifier) (*flow.EpochStatus, error)

func (*EpochStatuses) StoreTx

func (es *EpochStatuses) StoreTx(blockID flow.Identifier, status *flow.EpochStatus) func(tx *badger.Txn) error

type Events

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

func NewEvents

func NewEvents(db *badger.DB) *Events

func (*Events) ByBlockID

func (e *Events) ByBlockID(blockID flow.Identifier) ([]flow.Event, error)

ByBlockID returns the events for the given block ID

func (*Events) ByBlockIDEventType

func (e *Events) ByBlockIDEventType(blockID flow.Identifier, event flow.EventType) ([]flow.Event, error)

ByBlockIDEventType returns the events for the given block ID and event type

func (*Events) ByBlockIDTransactionID

func (e *Events) ByBlockIDTransactionID(blockID flow.Identifier, txID flow.Identifier) ([]flow.Event, error)

ByBlockIDTransactionID returns the events for the given block ID and transaction ID

func (*Events) Store

func (e *Events) Store(blockID flow.Identifier, events []flow.Event) error

Store will store events for the given block ID

type ExecutionReceipts

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

ExecutionReceipts implements storage for execution receipts.

func NewExecutionReceipts

func NewExecutionReceipts(collector module.CacheMetrics, db *badger.DB, results *ExecutionResults) *ExecutionReceipts

func (*ExecutionReceipts) ByBlockID

func (r *ExecutionReceipts) ByBlockID(blockID flow.Identifier) (*flow.ExecutionReceipt, error)

func (*ExecutionReceipts) ByBlockIDAllExecutionReceipts added in v0.14.0

func (r *ExecutionReceipts) ByBlockIDAllExecutionReceipts(blockID flow.Identifier) ([]*flow.ExecutionReceipt, error)

func (*ExecutionReceipts) ByID

func (*ExecutionReceipts) Index

func (r *ExecutionReceipts) Index(blockID, receiptID flow.Identifier) error

func (*ExecutionReceipts) IndexByExecutor added in v0.14.1

func (r *ExecutionReceipts) IndexByExecutor(receipt *flow.ExecutionReceipt) error

func (*ExecutionReceipts) Store

func (r *ExecutionReceipts) Store(receipt *flow.ExecutionReceipt) error

type ExecutionResults

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

ExecutionResults implements persistent storage for execution results.

func NewExecutionResults

func NewExecutionResults(collector module.CacheMetrics, db *badger.DB) *ExecutionResults

func (*ExecutionResults) ByBlockID

func (r *ExecutionResults) ByBlockID(blockID flow.Identifier) (*flow.ExecutionResult, error)

func (*ExecutionResults) ByID

func (r *ExecutionResults) ByID(resultID flow.Identifier) (*flow.ExecutionResult, error)

func (*ExecutionResults) Index

func (r *ExecutionResults) Index(blockID flow.Identifier, resultID flow.Identifier) error

func (*ExecutionResults) Store

func (r *ExecutionResults) Store(result *flow.ExecutionResult) error

type Guarantees

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

Guarantees implements persistent storage for collection guarantees.

func NewGuarantees

func NewGuarantees(collector module.CacheMetrics, db *badger.DB) *Guarantees

func (*Guarantees) ByCollectionID

func (g *Guarantees) ByCollectionID(collID flow.Identifier) (*flow.CollectionGuarantee, error)

func (*Guarantees) Store

func (g *Guarantees) Store(guarantee *flow.CollectionGuarantee) error

type Headers

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

Headers implements a simple read-only header storage around a badger DB.

func NewHeaders

func NewHeaders(collector module.CacheMetrics, db *badger.DB) *Headers

func (*Headers) ByBlockID

func (h *Headers) ByBlockID(blockID flow.Identifier) (*flow.Header, error)

func (*Headers) ByHeight

func (h *Headers) ByHeight(height uint64) (*flow.Header, error)

func (*Headers) ByParentID

func (h *Headers) ByParentID(parentID flow.Identifier) ([]*flow.Header, error)

func (*Headers) FindHeaders

func (h *Headers) FindHeaders(filter func(header *flow.Header) bool) ([]flow.Header, error)

func (*Headers) Store

func (h *Headers) Store(header *flow.Header) error

type Index

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

Index implements a simple read-only payload storage around a badger DB.

func NewIndex

func NewIndex(collector module.CacheMetrics, db *badger.DB) *Index

func (*Index) ByBlockID

func (i *Index) ByBlockID(blockID flow.Identifier) (*flow.Index, error)

func (*Index) Store

func (i *Index) Store(blockID flow.Identifier, index *flow.Index) error

type Payloads

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

func NewPayloads

func NewPayloads(db *badger.DB, index *Index, guarantees *Guarantees, seals *Seals, receipts *ExecutionReceipts) *Payloads

func (*Payloads) ByBlockID

func (p *Payloads) ByBlockID(blockID flow.Identifier) (*flow.Payload, error)

func (*Payloads) Store

func (p *Payloads) Store(blockID flow.Identifier, payload *flow.Payload) error

type ResultApprovals added in v0.14.0

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

ResultApprovals implements persistent storage for result approvals.

func NewResultApprovals added in v0.14.0

func NewResultApprovals(collector module.CacheMetrics, db *badger.DB) *ResultApprovals

func (*ResultApprovals) ByChunk added in v0.14.0

func (r *ResultApprovals) ByChunk(resultID flow.Identifier, chunkIndex uint64) (*flow.ResultApproval, error)

ByChunk retrieves a ResultApproval by result ID and chunk index. The ResultApprovals store is only used within a verification node, where it is assumed that there is never more than one approval per chunk.

func (*ResultApprovals) ByID added in v0.14.0

func (r *ResultApprovals) ByID(approvalID flow.Identifier) (*flow.ResultApproval, error)

ByID retrieves a ResultApproval by its ID

func (*ResultApprovals) Index added in v0.14.0

func (r *ResultApprovals) Index(resultID flow.Identifier, chunkIndex uint64, approvalID flow.Identifier) error

Index indexes a ResultApproval by chunk (ResultID + chunk index). operation is idempotent (repeated calls with the same value are equivalent to just calling the method once; still the method succeeds on each call).

func (*ResultApprovals) Store added in v0.14.0

func (r *ResultApprovals) Store(approval *flow.ResultApproval) error

Store stores a ResultApproval

type Seals

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

func NewSeals

func NewSeals(collector module.CacheMetrics, db *badger.DB) *Seals

func (*Seals) ByBlockID

func (s *Seals) ByBlockID(blockID flow.Identifier) (*flow.Seal, error)

func (*Seals) ByID

func (s *Seals) ByID(sealID flow.Identifier) (*flow.Seal, error)

func (*Seals) Store

func (s *Seals) Store(seal *flow.Seal) error

type ServiceEvents added in v0.14.0

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

func NewServiceEvents added in v0.14.0

func NewServiceEvents(db *badger.DB) *ServiceEvents

func (*ServiceEvents) ByBlockID added in v0.14.0

func (e *ServiceEvents) ByBlockID(blockID flow.Identifier) ([]flow.Event, error)

ByBlockID returns the events for the given block ID

func (*ServiceEvents) Store added in v0.14.0

func (e *ServiceEvents) Store(blockID flow.Identifier, events []flow.Event) error

Store will store events for the given block ID

type TransactionResults

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

func NewTransactionResults

func NewTransactionResults(db *badger.DB) *TransactionResults

func (*TransactionResults) BatchStore

func (tr *TransactionResults) BatchStore(blockID flow.Identifier, transactionResults []flow.TransactionResult) error

BatchStore will store the transaction results for the given block ID

func (*TransactionResults) ByBlockIDTransactionID

func (tr *TransactionResults) ByBlockIDTransactionID(blockID flow.Identifier, txID flow.Identifier) (*flow.TransactionResult, error)

ByBlockIDTransactionID returns the runtime transaction result for the given block ID and transaction ID

func (*TransactionResults) Store

func (tr *TransactionResults) Store(blockID flow.Identifier, transactionResult *flow.TransactionResult) error

Store will store the transaction result for the given block ID

type Transactions

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

Transactions ...

func NewTransactions

func NewTransactions(cacheMetrics module.CacheMetrics, db *badger.DB) *Transactions

NewTransactions ...

func (*Transactions) ByID

ByID ...

func (*Transactions) Store

func (t *Transactions) Store(flowTx *flow.TransactionBody) error

Store ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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