stdmap

package
v0.35.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: AGPL-3.0 Imports: 17 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EjectPanic

func EjectPanic(b *Backend) (flow.Identifier, flow.Entity, bool)

EjectPanic simply panics, crashing the program. Useful when cache is not expected to grow beyond certain limits, but ejecting is not applicable

func EjectRandomFast added in v0.32.0

func EjectRandomFast(b *Backend) (bool, error)

EjectRandomFast checks if the map size is beyond the threshold size, and will iterate through them and eject unneeded entries if that is the case. Return values are unused

Types

type Assignments

type Assignments struct {
	*Backend
}

Assignments implements the chunk assignment memory pool.

func NewAssignments

func NewAssignments(limit uint) (*Assignments, error)

NewAssignments creates a new memory pool for Assignments.

func (*Assignments) Add

func (a *Assignments) Add(fingerprint flow.Identifier, assignment *chunkmodels.Assignment) bool

Add adds an Assignment to the mempool.

func (*Assignments) All

func (a *Assignments) All() []*chunkmodels.Assignment

All returns all chunk data packs from the pool.

func (*Assignments) ByID

func (a *Assignments) ByID(assignmentID flow.Identifier) (*chunkmodels.Assignment, bool)

ByID retrieves the chunk assignment from mempool based on provided ID

func (*Assignments) Has

func (a *Assignments) Has(assignmentID flow.Identifier) bool

Has checks whether the Assignment with the given hash is currently in the memory pool.

func (*Assignments) Remove added in v0.27.0

func (a *Assignments) Remove(assignmentID flow.Identifier) bool

Remove will remove the given Assignment from the memory pool; it will return true if the Assignment was known and removed.

func (*Assignments) Size

func (a *Assignments) Size() uint

Size will return the current size of the memory pool.

type Backend

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

Backend is a wrapper around the backdata that provides concurrency-safe operations.

func NewBackend

func NewBackend(options ...OptionFunc) *Backend

NewBackend creates a new memory pool backend. This is using EjectRandomFast()

func (*Backend) Add

func (b *Backend) Add(entity flow.Entity) bool

Add adds the given item to the pool.

func (*Backend) Adjust

func (b *Backend) Adjust(entityID flow.Identifier, f func(flow.Entity) flow.Entity) (flow.Entity, bool)

Adjust will adjust the value item using the given function if the given key can be found. Returns a bool which indicates whether the value was updated.

func (*Backend) AdjustWithInit added in v0.33.1

func (b *Backend) AdjustWithInit(entityID flow.Identifier, adjust func(flow.Entity) flow.Entity, init func() flow.Entity) (flow.Entity, bool)

AdjustWithInit adjusts the entity using the given function if the given identifier can be found. When the entity is not found, it initializes the entity using the given init function and then applies the adjust function. Args: - entityID: the identifier of the entity to adjust. - adjust: the function that adjusts the entity. - init: the function that initializes the entity when it is not found. Returns:

  • the adjusted entity.

- a bool which indicates whether the entity was adjusted.

func (*Backend) All

func (b *Backend) All() []flow.Entity

All returns all entities from the pool.

func (*Backend) ByID

func (b *Backend) ByID(entityID flow.Identifier) (flow.Entity, bool)

ByID returns the given item from the pool.

func (*Backend) Clear added in v0.11.0

func (b *Backend) Clear()

Clear removes all entities from the pool.

func (*Backend) GetWithInit added in v0.33.1

func (b *Backend) GetWithInit(entityID flow.Identifier, init func() flow.Entity) (flow.Entity, bool)

GetWithInit returns the given entity from the backdata. If the entity does not exist, it creates a new entity using the factory function and stores it in the backdata. Args: - entityID: the identifier of the entity to get. - init: the function that initializes the entity when it is not found. Returns:

  • the entity.

- a bool which indicates whether the entity was found (or created).

func (*Backend) Has

func (b *Backend) Has(entityID flow.Identifier) bool

Has checks if we already contain the item with the given hash.

func (*Backend) Limit

func (b *Backend) Limit() uint

Limit returns the maximum number of items allowed in the backend.

func (*Backend) RegisterEjectionCallbacks added in v0.13.0

func (b *Backend) RegisterEjectionCallbacks(callbacks ...mempool.OnEjection)

RegisterEjectionCallbacks adds the provided OnEjection callbacks

func (*Backend) Remove added in v0.27.0

func (b *Backend) Remove(entityID flow.Identifier) bool

Remove will remove the item with the given hash.

func (*Backend) Run

func (b *Backend) Run(f func(backdata mempool.BackData) error) error

Run executes a function giving it exclusive access to the backdata

func (*Backend) Size

func (b *Backend) Size() uint

Size will return the size of the backend.

type BatchEjectFunc added in v0.21.0

type BatchEjectFunc func(b *Backend) (bool, error)

BatchEjectFunc implements an ejection policy to remove elements when the mempool exceeds its specified capacity. A custom ejection policy can be injected into the memory pool upon creation to change the strategy of eviction. The ejection policy is executed from within the thread that serves the mempool. Implementations should adhere to the following convention:

  • The ejector function has the freedom to eject _multiple_ elements.
  • In a single `eject` call, it must eject as many elements to statistically keep the mempool size within the desired limit.
  • The ejector _might_ (for performance reasons) retain more elements in the mempool than the targeted capacity.
  • The ejector _must_ notify the `Backend.ejectionCallbacks` for _each_ element it removes from the mempool.
  • Implementations do _not_ need to be concurrency safe. The Backend handles concurrency (specifically, it locks the mempool during ejection).
  • The implementation should be non-blocking (though, it is allowed to take a bit of time; the mempool will just be locked during this time).

type BlockByCollectionBackdata

type BlockByCollectionBackdata struct {
	mempool.BackData
}

BlockByCollectionBackdata contains all the collections is being requested, for each collection it stores the blocks that contains the collection. the Backdata is essentially map<collectionID>map<blockID>*ExecutableBlock

func (*BlockByCollectionBackdata) ByID

type BlockByCollections

type BlockByCollections struct {
	*Backend
}

Hold all the missing collections. Each entry is a missing collection, and all the blocks that contain this collection

func NewBlockByCollections

func NewBlockByCollections() *BlockByCollections

func (*BlockByCollections) Add

func (*BlockByCollections) Get

func (*BlockByCollections) Run

func (b *BlockByCollections) Run(f func(backdata *BlockByCollectionBackdata) error) error

type Blocks

type Blocks struct {
	*Backend
}

Blocks implements the blocks memory pool.

func NewBlocks

func NewBlocks(limit uint) (*Blocks, error)

NewBlocks creates a new memory pool for blocks.

func (*Blocks) Add

func (a *Blocks) Add(block *flow.Block) bool

Add adds an block to the mempool.

func (*Blocks) All

func (a *Blocks) All() []*flow.Block

All returns all blocks from the pool.

func (*Blocks) ByID

func (a *Blocks) ByID(blockID flow.Identifier) (*flow.Block, bool)

ByID returns the block with the given ID from the mempool.

type ChunkDataPacks

type ChunkDataPacks struct {
	*Backend
}

ChunkDataPacks implements the ChunkDataPack memory pool.

func NewChunkDataPacks

func NewChunkDataPacks(limit uint) (*ChunkDataPacks, error)

NewChunkDataPacks creates a new memory pool for ChunkDataPacks.

func (*ChunkDataPacks) Add

func (c *ChunkDataPacks) Add(cdp *flow.ChunkDataPack) bool

Add adds an chunkDataPack to the mempool.

func (*ChunkDataPacks) All

func (c *ChunkDataPacks) All() []*flow.ChunkDataPack

All returns all chunk data packs from the pool.

func (*ChunkDataPacks) ByChunkID

func (c *ChunkDataPacks) ByChunkID(chunkID flow.Identifier) (*flow.ChunkDataPack, bool)

ByChunkID returns the chunk data pack with the given chunkID from the mempool.

func (*ChunkDataPacks) Has

func (c *ChunkDataPacks) Has(chunkID flow.Identifier) bool

Has checks whether the ChunkDataPack with the given chunkID is currently in the memory pool.

func (*ChunkDataPacks) Remove added in v0.27.0

func (c *ChunkDataPacks) Remove(chunkID flow.Identifier) bool

Remove will remove chunk data pack by ID

func (*ChunkDataPacks) Size

func (c *ChunkDataPacks) Size() uint

Size will return the current size of the memory pool.

type ChunkRequests added in v0.17.0

type ChunkRequests struct {
	*Backend
}

ChunkRequests is an implementation of in-memory storage for maintaining chunk requests data objects.

In this implementation, the ChunkRequests wraps the ChunkDataPackRequests around an internal ChunkRequestStatus data object, and maintains the wrapped version in memory.

func NewChunkRequests added in v0.17.0

func NewChunkRequests(limit uint) *ChunkRequests

func (*ChunkRequests) Add added in v0.17.0

Add provides insertion functionality into the memory pool. The insertion is only successful if there is no duplicate chunk request for the same tuple of (chunkID, resultID, chunkIndex).

func (*ChunkRequests) All added in v0.17.0

All returns all chunk requests stored in this memory pool.

func (*ChunkRequests) IncrementAttempt added in v0.17.0

func (cs *ChunkRequests) IncrementAttempt(chunkID flow.Identifier) bool

IncrementAttempt increments the Attempt field of the corresponding status of the chunk request in memory pool that has the specified chunk ID. If such chunk ID does not exist in the memory pool, it returns false.

The increments are done atomically, thread-safe, and in isolation.

func (*ChunkRequests) PopAll added in v0.23.2

func (cs *ChunkRequests) PopAll(chunkID flow.Identifier) (chunks.LocatorMap, bool)

PopAll atomically returns all locators associated with this chunk ID while clearing out the chunk request status for this chunk id. Boolean return value indicates whether there are requests in the memory pool associated with chunk ID.

func (*ChunkRequests) Remove added in v0.27.0

func (cs *ChunkRequests) Remove(chunkID flow.Identifier) bool

Remove provides deletion functionality from the memory pool. If there is a chunk request with this ID, Remove removes it and returns true. Otherwise it returns false.

func (*ChunkRequests) RequestHistory added in v0.17.0

func (cs *ChunkRequests) RequestHistory(chunkID flow.Identifier) (uint64, time.Time, time.Duration, bool)

RequestHistory returns the number of times the chunk has been requested, last time the chunk has been requested, and the retryAfter duration of the underlying request status of this chunk.

The last boolean parameter returns whether a chunk request for this chunk ID exists in memory-pool.

func (ChunkRequests) Size added in v0.17.1

func (cs ChunkRequests) Size() uint

Size returns total number of chunk requests in the memory pool.

func (*ChunkRequests) UpdateRequestHistory added in v0.17.0

func (cs *ChunkRequests) UpdateRequestHistory(chunkID flow.Identifier, updater mempool.ChunkRequestHistoryUpdaterFunc) (uint64, time.Time, time.Duration, bool)

UpdateRequestHistory updates the request history of the specified chunk ID. If the update was successful, i.e., the updater returns true, the result of update is committed to the mempool, and the time stamp of the chunk request is updated to the current time. Otherwise, it aborts and returns false.

It returns the updated request history values.

The updates under this method are atomic, thread-safe, and done in isolation.

type ChunkStatuses added in v0.17.0

type ChunkStatuses struct {
	*Backend
}

ChunkStatuses is an implementation of in-memory storage for maintaining the chunk status data objects.

func NewChunkStatuses added in v0.17.0

func NewChunkStatuses(limit uint) *ChunkStatuses

func (*ChunkStatuses) Add added in v0.17.0

func (cs *ChunkStatuses) Add(status *verification.ChunkStatus) bool

Add provides insertion functionality into the memory pool. The insertion is only successful if there is no duplicate status with the same chunk ID in the memory. Otherwise, it aborts the insertion and returns false.

func (ChunkStatuses) All added in v0.17.0

All returns all chunk statuses stored in this memory pool.

func (ChunkStatuses) Get added in v0.23.2

func (cs ChunkStatuses) Get(chunkIndex uint64, resultID flow.Identifier) (*verification.ChunkStatus, bool)

Get returns a chunk status by its chunk index and result ID. There is a one-to-one correspondence between the chunk statuses in memory, and their pair of chunk index and result id.

func (*ChunkStatuses) Remove added in v0.27.0

func (cs *ChunkStatuses) Remove(chunkIndex uint64, resultID flow.Identifier) bool

Remove provides deletion functionality from the memory pool based on the pair of chunk index and result id. If there is a chunk status associated with this pair, Remove removes it and returns true. Otherwise, it returns false.

func (ChunkStatuses) Size added in v0.17.1

func (cs ChunkStatuses) Size() uint

Size returns total number of chunk statuses in the memory pool.

type Collections

type Collections struct {
	*Backend
}

Collections implements a mempool storing collections.

func NewCollections

func NewCollections(limit uint) (*Collections, error)

NewCollections creates a new memory pool for collection.

func (*Collections) Add

func (c *Collections) Add(coll *flow.Collection) bool

Add adds a collection to the mempool.

func (*Collections) All

func (c *Collections) All() []*flow.Collection

All returns all collections from the mempool.

func (*Collections) ByID

func (c *Collections) ByID(collID flow.Identifier) (*flow.Collection, bool)

ByID returns the collection with the given ID from the mempool.

func (*Collections) Remove added in v0.27.0

func (c *Collections) Remove(collID flow.Identifier) bool

Remove removes a collection by ID from memory

type EjectFunc

type EjectFunc func(b *Backend) (flow.Identifier, flow.Entity, bool)

type Guarantees

type Guarantees struct {
	*Backend
}

Guarantees implements the collections memory pool of the consensus nodes, used to store collection guarantees and to generate block payloads.

func NewGuarantees

func NewGuarantees(limit uint) (*Guarantees, error)

NewGuarantees creates a new memory pool for collection guarantees.

func (*Guarantees) Add

func (g *Guarantees) Add(guarantee *flow.CollectionGuarantee) bool

Add adds a collection guarantee guarantee to the mempool.

func (*Guarantees) All

func (g *Guarantees) All() []*flow.CollectionGuarantee

All returns all collection guarantees from the mempool.

func (*Guarantees) ByID

func (g *Guarantees) ByID(collID flow.Identifier) (*flow.CollectionGuarantee, bool)

ByID returns the collection guarantee with the given ID from the mempool.

type IdentifierMap

type IdentifierMap struct {
	*Backend
}

IdentifierMap represents a concurrency-safe memory pool for IdMapEntity.

func NewIdentifierMap

func NewIdentifierMap(limit uint) (*IdentifierMap, error)

NewIdentifierMap creates a new memory pool for IdMapEntity.

func (*IdentifierMap) Append

func (i *IdentifierMap) Append(key, id flow.Identifier) error

Append will append the id to the list of identifiers associated with key.

func (*IdentifierMap) Get

func (i *IdentifierMap) Get(key flow.Identifier) ([]flow.Identifier, bool)

Get returns list of all identifiers associated with key and true, if the key exists in the mempool. Otherwise it returns nil and false.

func (*IdentifierMap) Has

func (i *IdentifierMap) Has(key flow.Identifier) bool

Has returns true if the key exists in the map, i.e., there is at least an id attached to it.

func (*IdentifierMap) Keys

func (i *IdentifierMap) Keys() ([]flow.Identifier, bool)

Keys returns a list of all keys in the mempool

func (*IdentifierMap) Remove added in v0.27.0

func (i *IdentifierMap) Remove(key flow.Identifier) bool

Remove removes the given key with all associated identifiers.

func (*IdentifierMap) RemoveIdFromKey added in v0.27.0

func (i *IdentifierMap) RemoveIdFromKey(key, id flow.Identifier) error

RemoveIdFromKey removes the id from the list of identifiers associated with key. If the list becomes empty, it also removes the key from the map.

func (*IdentifierMap) Size

func (i *IdentifierMap) Size() uint

Size returns number of IdMapEntities in mempool

type Identifiers

type Identifiers struct {
	*Backend
}

Identifiers represents a concurrency-safe memory pool for IDs.

func NewIdentifiers

func NewIdentifiers(limit uint) (*Identifiers, error)

NewIdentifiers creates a new memory pool for identifiers.

func (*Identifiers) Add

func (i *Identifiers) Add(id flow.Identifier) bool

Add will add the given identifier to the memory pool or it will error if the identifier is already in the memory pool.

func (*Identifiers) All

func (i *Identifiers) All() flow.IdentifierList

All returns all identifiers stored in the mempool

func (*Identifiers) Has

func (i *Identifiers) Has(id flow.Identifier) bool

Has checks whether the mempool has the identifier

func (*Identifiers) Remove added in v0.27.0

func (i *Identifiers) Remove(id flow.Identifier) bool

Remove removes the given identifier from the memory pool; it will return true if the identifier was known and removed.

type IncorporatedResultSeals added in v0.11.0

type IncorporatedResultSeals struct {
	*Backend
	// contains filtered or unexported fields
}

IncorporatedResultSeals implements the incorporated result seals memory pool of the consensus nodes, used to store seals that need to be added to blocks. ATTENTION: This data structure should NEVER eject seals because it can break liveness. Modules that are using this structure expect that it NEVER ejects a seal.

func NewIncorporatedResultSeals added in v0.11.0

func NewIncorporatedResultSeals(limit uint) *IncorporatedResultSeals

NewIncorporatedResultSeals creates a mempool for the incorporated result seals

func (*IncorporatedResultSeals) Add added in v0.11.0

Add adds an IncorporatedResultSeal to the mempool

func (*IncorporatedResultSeals) All added in v0.11.0

All returns all the items in the mempool

func (*IncorporatedResultSeals) ByID added in v0.11.0

ByID gets an IncorporatedResultSeal by IncorporatedResult ID

func (*IncorporatedResultSeals) Clear added in v0.13.0

func (ir *IncorporatedResultSeals) Clear()

func (*IncorporatedResultSeals) PruneUpToHeight added in v0.18.1

func (ir *IncorporatedResultSeals) PruneUpToHeight(height uint64) error

PruneUpToHeight remove all seals for blocks whose height is strictly smaller that height. Note: seals for blocks at height are retained. After pruning, seals below for blocks below the given height are dropped.

Monotonicity Requirement: The pruned height cannot decrease, as we cannot recover already pruned elements. If `height` is smaller than the previous value, the previous value is kept and the sentinel mempool.BelowPrunedThresholdError is returned.

func (*IncorporatedResultSeals) Remove added in v0.27.0

Remove removes an IncorporatedResultSeal from the mempool

func (*IncorporatedResultSeals) Size added in v0.19.0

func (ir *IncorporatedResultSeals) Size() uint

Size returns the size of the underlying backing store

type LRUEjector

type LRUEjector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LRUEjector provides a swift FIFO ejection functionality

func NewLRUEjector

func NewLRUEjector() *LRUEjector

func (*LRUEjector) Eject

func (q *LRUEjector) Eject(b *Backend) flow.Identifier

Eject implements EjectFunc for LRUEjector. It finds the entity with the lowest sequence number (i.e., the oldest entity). It also untracks. This is using a linear search

func (*LRUEjector) Track

func (q *LRUEjector) Track(entityID flow.Identifier)

Track should be called every time a new entity is added to the mempool. It tracks the entity for later ejection.

func (*LRUEjector) Untrack

func (q *LRUEjector) Untrack(entityID flow.Identifier)

Untrack simply removes the tracker of the ejector off the entityID

type OptionFunc

type OptionFunc func(*Backend)

OptionFunc is a function that can be provided to the backend on creation in order to set a certain custom option.

func WithBackData added in v0.25.2

func WithBackData(backdata mempool.BackData) OptionFunc

WithBackData sets the underlying backdata of the backend. BackData represents the underlying data structure that is utilized by mempool.Backend, as the core structure of maintaining data on memory-pools.

func WithEject

func WithEject(eject EjectFunc) OptionFunc

WithEject can be provided to the backend on creation in order to set a custom eject function to pick the entity to be evicted upon overflow, as well as hooking into it for additional cleanup work.

func WithLimit

func WithLimit(limit uint) OptionFunc

WithLimit can be provided to the backend on creation in order to set a point where it's time to check for ejection conditions. The actual size may continue to rise by the threshold for batch ejection (currently 128)

type PendingReceipts added in v0.14.1

type PendingReceipts struct {
	*Backend
	// contains filtered or unexported fields
}

PendingReceipts stores pending receipts indexed by the id. It also maintains a secondary index on the previous result id. in order to allow to find receipts by the previous result id.

func NewPendingReceipts added in v0.14.1

func NewPendingReceipts(headers storage.Headers, limit uint) *PendingReceipts

NewPendingReceipts creates a new memory pool for execution receipts.

func (*PendingReceipts) Add added in v0.14.1

func (r *PendingReceipts) Add(receipt *flow.ExecutionReceipt) bool

Add adds an execution receipt to the mempool.

func (*PendingReceipts) ByPreviousResultID added in v0.14.1

func (r *PendingReceipts) ByPreviousResultID(previousResultID flow.Identifier) []*flow.ExecutionReceipt

ByPreviousResultID returns receipts whose previous result ID matches the given ID

func (*PendingReceipts) PruneUpToHeight added in v0.19.0

func (r *PendingReceipts) PruneUpToHeight(height uint64) error

PruneUpToHeight remove all receipts for blocks whose height is strictly smaller that height. Note: receipts for blocks at height are retained. After pruning, receipts below for blocks below the given height are dropped.

Monotonicity Requirement: The pruned height cannot decrease, as we cannot recover already pruned elements. If `height` is smaller than the previous value, the previous value is kept and the sentinel mempool.BelowPrunedThresholdError is returned.

func (*PendingReceipts) Remove added in v0.27.0

func (r *PendingReceipts) Remove(receiptID flow.Identifier) bool

Remove will remove a receipt by ID.

func (*PendingReceipts) Size added in v0.14.1

func (r *PendingReceipts) Size() uint

Size will return the total number of pending receipts

type Queues

type Queues struct {
	*Backend
}

func NewQueues

func NewQueues() *Queues

func (*Queues) Add

func (b *Queues) Add(queue *queue.Queue) bool

func (*Queues) Get

func (b *Queues) Get(queueID flow.Identifier) (*queue.Queue, bool)

func (*Queues) Run

func (b *Queues) Run(f func(backdata *QueuesBackdata) error) error

type QueuesBackdata

type QueuesBackdata struct {
	mempool.BackData
}

QueuesBackdata is mempool map for ingestion.Queues (head Node ID -> Queues)

func (*QueuesBackdata) All

func (b *QueuesBackdata) All() []*queue.Queue

func (*QueuesBackdata) ByID

func (b *QueuesBackdata) ByID(queueID flow.Identifier) (*queue.Queue, bool)

type Receipts

type Receipts struct {
	*Backend
}

Receipts implements the execution receipts memory pool of the consensus node, used to store execution receipts and to generate block seals.

func NewReceipts

func NewReceipts(limit uint) (*Receipts, error)

NewReceipts creates a new memory pool for execution receipts.

func (*Receipts) Add

func (r *Receipts) Add(receipt *flow.ExecutionReceipt) bool

Add adds an execution receipt to the mempool.

func (*Receipts) All

func (r *Receipts) All() []*flow.ExecutionReceipt

All will return all execution receipts in the memory pool.

func (*Receipts) ByID

func (r *Receipts) ByID(receiptID flow.Identifier) (*flow.ExecutionReceipt, bool)

ByID will retrieve an approval by ID.

func (*Receipts) Remove added in v0.27.0

func (r *Receipts) Remove(receiptID flow.Identifier) bool

Remove will remove a receipt by ID.

type Results

type Results struct {
	*Backend
}

Results implements the execution results memory pool of the consensus node, used to store execution results and to generate block seals.

func NewResults

func NewResults(limit uint) (*Results, error)

NewResults creates a new memory pool for execution results.

func (*Results) Add

func (r *Results) Add(result *flow.ExecutionResult) bool

Add adds an execution result to the mempool.

func (*Results) All

func (r *Results) All() []*flow.ExecutionResult

All will return all execution results in the memory pool.

func (*Results) ByID

func (r *Results) ByID(resultID flow.Identifier) (*flow.ExecutionResult, bool)

ByID will retrieve an approval by ID.

func (*Results) Remove added in v0.27.0

func (r *Results) Remove(resultID flow.Identifier) bool

Remove will remove a result by ID.

type Time

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

func (*Time) Checksum

func (t *Time) Checksum() flow.Identifier

func (*Time) ID

func (t *Time) ID() flow.Identifier

type Times

type Times struct {
	*Backend
}

Times implements the times memory pool used to store time.Times for an idetifier to track transaction metrics in access nodes

func NewTimes

func NewTimes(limit uint) (*Times, error)

NewTimes creates a new memory pool for times

func (*Times) Add

func (t *Times) Add(id flow.Identifier, ti time.Time) bool

Add adds a time to the mempool.

func (*Times) ByID

func (t *Times) ByID(id flow.Identifier) (time.Time, bool)

ByID returns the time with the given ID from the mempool.

func (*Times) Remove added in v0.27.0

func (t *Times) Remove(id flow.Identifier) bool

Remove removes the time with the given ID.

type TransactionTimings

type TransactionTimings struct {
	*Backend
}

TransactionTimings implements the transaction timings memory pool of access nodes, used to store transaction timings to report the timing of individual transactions

func NewTransactionTimings

func NewTransactionTimings(limit uint) (*TransactionTimings, error)

NewTransactionTimings creates a new memory pool for transaction timings

func (*TransactionTimings) Add

Add adds a transaction timing to the mempool.

func (*TransactionTimings) Adjust

Adjust will adjust the transaction timing using the given function if the given key can be found. Returns a bool which indicates whether the value was updated as well as the updated value.

func (*TransactionTimings) All

All returns all transaction timings from the mempool.

func (*TransactionTimings) ByID

ByID returns the transaction timing with the given ID from the mempool.

func (*TransactionTimings) Remove added in v0.27.0

func (t *TransactionTimings) Remove(txID flow.Identifier) bool

Remove removes the transaction timing with the given ID.

type Transactions

type Transactions struct {
	*Backend
}

Transactions implements the transactions memory pool of the consensus nodes, used to store transactions and to generate block payloads.

func NewTransactions

func NewTransactions(limit uint) *Transactions

NewTransactions creates a new memory pool for transactions. Deprecated: use herocache.Transactions instead.

func (*Transactions) Add

func (t *Transactions) Add(tx *flow.TransactionBody) bool

Add adds a transaction to the mempool.

func (*Transactions) All

func (t *Transactions) All() []*flow.TransactionBody

All returns all transactions from the mempool.

func (*Transactions) ByID

ByID returns the transaction with the given ID from the mempool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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