txretainer

package
v1.0.0-alpha.19 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEntryNotFound is returned when a transaction metadata entry is not found.
	ErrEntryNotFound = ierrors.New("entry not found")
)

Functions

func NewProvider

NewProvider creates a new TransactionRetainer provider.

func NewTransactionRetainerCache

func NewTransactionRetainerCache(opts ...options.Option[transactionRetainerCache]) *transactionRetainerCache

NewTransactionRetainerCache creates a new transaction retainer cache.

func NewTransactionRetainerDB

func NewTransactionRetainerDB(dbExecFunc storage.SQLDatabaseExecFunc) *transactionRetainerDatabase

NewTransactionRetainerDB creates a new transaction retainer database.

func WithDebugStoreErrorMessages

func WithDebugStoreErrorMessages(store bool) options.Option[TransactionRetainer]

WithDebugStoreErrorMessages configures the TransactionRetainer to store debug error messages.

func WithTxRetainerCacheTxMetadataUpdateFunc

func WithTxRetainerCacheTxMetadataUpdateFunc(updateFunc txMetadataUpdateFunc) options.Option[transactionRetainerCache]

WithTxRetainerCacheTxMetadataUpdateFunc is an option for the transaction retainer cache that allows to set a custom update function for transaction metadata.

Types

type SlotFunc

type SlotFunc func() iotago.SlotIndex

type TransactionMetadata

type TransactionMetadata struct {
	ID                     uint64           `gorm:"autoIncrement"`
	TransactionID          []byte           `gorm:"notnull;index:transaction_ids"`
	ValidSignature         bool             `gorm:"notnull"`
	EarliestAttachmentSlot iotago.SlotIndex `gorm:"notnull"`
	State                  byte             `gorm:"notnull"`
	FailureReason          byte             `gorm:"notnull"`
	ErrorMsg               *string
}

TransactionMetadata represents the metadata of a transaction in the SQL database and the cache. The ID is the primary key of the database table. We need this ID because we want to be able to store multiple metadata entries for the same transaction ID, but with different earliest attachment slots. This is necessary because we want to be able to rollback the transaction retainer to a specific slot by deleting all entries with an earliest attachment slot greater than the target slot.

func (*TransactionMetadata) Equal

func (m *TransactionMetadata) Equal(other *TransactionMetadata) bool

Equal compares everything except the Database ID.

func (*TransactionMetadata) String

func (m *TransactionMetadata) String() string

type TransactionRetainer

type TransactionRetainer struct {
	module.Module
	// contains filtered or unexported fields
}

TransactionRetainer keeps and resolves all the transaction-related metadata needed in the API and INX.

func New

func New(subModule module.Module, workersGroup *workerpool.Group, dbExecFunc storage.SQLDatabaseExecFunc, latestCommittedSlotFunc SlotFunc, finalizedSlotFunc SlotFunc, errorHandler func(error), opts ...options.Option[TransactionRetainer]) *TransactionRetainer

func (*TransactionRetainer) CommitSlot

func (r *TransactionRetainer) CommitSlot(slot iotago.SlotIndex) error

CommitSlot applies all uncommitted changes of a slot from the cache to the database and deletes them from the cache.

func (*TransactionRetainer) Prune

func (r *TransactionRetainer) Prune(targetSlot iotago.SlotIndex) error

Prune prunes the component state as if the last pruned slot was targetSlot.

func (*TransactionRetainer) Reset

func (r *TransactionRetainer) Reset(targetSlot iotago.SlotIndex)

Reset resets the component to a clean state as if it was created at the last commitment.

func (*TransactionRetainer) TransactionMetadata

TransactionMetadata returns the metadata of a transaction.

func (*TransactionRetainer) UpdateTransactionMetadata

func (r *TransactionRetainer) UpdateTransactionMetadata(txID iotago.TransactionID, validSignature bool, earliestAttachmentSlot iotago.SlotIndex, state api.TransactionState, txErr error)

UpdateTransactionMetadata updates the metadata of a transaction. The changes will be applied to the cache and later to the database by "CommitSlot".

Jump to

Keyboard shortcuts

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