finality

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRetry = 3

Variables

This section is empty.

Functions

func Commit

func Commit(
	ctx context.Context,
	logger logging.Logger,
	tokens tokensService,
	ttxDB transactionDB,
	txID string,
	tr *token.Request,
) error

Types

type Listener

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

func NewListener

func NewListener(
	logger logging.Logger,
	net dep.Network,
	namespace string,
	hasher tokenRequestHasher,
	ttxDB transactionDB,
	tokens tokensService,
	tracer trace.Tracer,
	metricsProvider metrics.Provider,
) *Listener

func (*Listener) OnError

func (t *Listener) OnError(ctx context.Context, txID string, err error)

OnError is called when a finality event for txID could not be delivered after all retries.

func (*Listener) OnStatus

func (t *Listener) OnStatus(ctx context.Context, txID string, status int, message string, tokenRequestHash []byte)

type Metrics

type Metrics struct {
	// ConfirmedTransactions counts transactions whose ledger status resolved to
	// Valid and whose token-request hash matched, i.e. fully committed.
	ConfirmedTransactions metrics.Counter

	// DeletedTransactions counts transactions whose ledger status resolved to
	// Invalid, or whose token-request hash did not match (integrity failure).
	DeletedTransactions metrics.Counter

	// HashMismatches counts the subset of deleted transactions that were
	// invalidated specifically because the committed token-request hash did not
	// match the locally stored one. Non-zero values indicate a data-integrity
	// violation worth alerting on.
	HashMismatches metrics.Counter

	// RetryExhausted counts calls to OnError, i.e. how many transactions had
	// their finality processing abandoned after all retries were exhausted.
	RetryExhausted metrics.Counter

	// OnStatusDuration is a histogram of the total wall-clock time for each
	// OnStatus invocation (including any retries), measured in seconds.
	OnStatusDuration metrics.Histogram
}

Metrics holds the instrumentation for the finality Listener.

func NewMetrics

func NewMetrics(p metrics.Provider) *Metrics

NewMetrics creates a new Metrics instance with the given provider. This is exported for use by other packages that need finality metrics.

type TTXRecoveryHandler

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

TTXRecoveryHandler implements transaction recovery by directly querying transaction status and applying finality logic synchronously

func NewTTXRecoveryHandler

func NewTTXRecoveryHandler(
	logger logging.Logger,
	network networkService,
	namespace string,
	hasher tokenRequestHasher,
	tmsID token.TMSID,
	transactionDB transactionDB,
	tokens tokensService,
	tracer trace.Tracer,
	metricsProvider metrics.Provider,
) *TTXRecoveryHandler

NewTTXRecoveryHandler creates a new recovery handler with all dependencies needed to perform synchronous transaction recovery

func (*TTXRecoveryHandler) Recover

func (h *TTXRecoveryHandler) Recover(ctx context.Context, txID string) error

Recover attempts to recover a transaction by querying its status and applying finality logic. This is a synchronous operation that does not use listeners or retries.

type TokenRequestHasher

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

TokenRequestHasher processes token requests from raw bytes

func NewTokenRequestHasher

func NewTokenRequestHasher(tmsProvider dep.TokenManagementServiceProvider, tmsID token.TMSID) *TokenRequestHasher

NewTokenRequestHasher creates a new token request hasher

func (*TokenRequestHasher) ProcessTokenRequest

func (h *TokenRequestHasher) ProcessTokenRequest(ctx context.Context, tokenRequestRaw []byte) (tr *token.Request, msgToSign []byte, err error)

ProcessTokenRequest processes a raw token request and returns the request and message to sign

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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