Documentation ¶
Index ¶
- Variables
- func NewProvider(opts ...options.Option[TransactionRetainer]) module.Provider[*engine.Engine, retainer.TransactionRetainer]
- func NewTransactionRetainerCache(opts ...options.Option[transactionRetainerCache]) *transactionRetainerCache
- func NewTransactionRetainerDB(dbExecFunc storage.SQLDatabaseExecFunc) *transactionRetainerDatabase
- func WithDebugStoreErrorMessages(store bool) options.Option[TransactionRetainer]
- func WithTxRetainerCacheTxMetadataUpdateFunc(updateFunc txMetadataUpdateFunc) options.Option[transactionRetainerCache]
- type SlotFunc
- type TransactionMetadata
- type TransactionRetainer
- func (r *TransactionRetainer) CommitSlot(slot iotago.SlotIndex) error
- func (r *TransactionRetainer) Prune(targetSlot iotago.SlotIndex) error
- func (r *TransactionRetainer) Reset(targetSlot iotago.SlotIndex)
- func (r *TransactionRetainer) TransactionMetadata(txID iotago.TransactionID) (*api.TransactionMetadataResponse, error)
- func (r *TransactionRetainer) UpdateTransactionMetadata(txID iotago.TransactionID, validSignature bool, ...)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEntryNotFound is returned when a transaction metadata entry is not found. ErrEntryNotFound = ierrors.New("entry not found") )
Functions ¶
func NewProvider ¶
func NewProvider(opts ...options.Option[TransactionRetainer]) module.Provider[*engine.Engine, retainer.TransactionRetainer]
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 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 ¶
TransactionRetainer keeps and resolves all the transaction-related metadata needed in the API and INX.
func New ¶
func New(parentModule 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 ¶
func (r *TransactionRetainer) TransactionMetadata(txID iotago.TransactionID) (*api.TransactionMetadataResponse, error)
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".