MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / transaction

Interface transaction

database/repository.go:43–79  ·  view source on GitHub ↗

transaction defines methods for handling transactions.

Source from the content-addressed store, hash-verified

41
42// transaction defines methods for handling transactions.
43type transaction interface {
44 RecordTransaction(cxt context.Context, txn *model.Transaction) (*model.Transaction, error) // Records a new transaction
45 RecordTransactionWithBalances(ctx context.Context, txn *model.Transaction, sourceBalance, destinationBalance *model.Balance) (*model.Transaction, error) // Records a transaction with balance updates atomically
46 RecordTransactionWithBalancesAndOutbox(ctx context.Context, txn *model.Transaction, sourceBalance, destinationBalance *model.Balance, outbox *model.LineageOutbox) (*model.Transaction, error) // Records a transaction with balance updates and optional lineage outbox atomically
47 RecordTransactionsWithBalancesAndOutboxes(ctx context.Context, txns []*model.Transaction, sourceBalance, destinationBalance *model.Balance, outboxes []*model.LineageOutbox) ([]*model.Transaction, error)
48 RecordTransactionsWithBalanceSetAndOutboxes(ctx context.Context, txns []*model.Transaction, balances []*model.Balance, outboxes []*model.LineageOutbox) ([]*model.Transaction, error)
49 GetTransaction(cxt context.Context, id string) (*model.Transaction, error) // Retrieves a transaction by ID
50 IsParentTransactionVoid(cxt context.Context, parentID string) (bool, error) // Checks if a parent transaction is void
51 GetTransactionByRef(cxt context.Context, reference string) (model.Transaction, error) // Retrieves a transaction by reference
52 TransactionExistsByRef(ctx context.Context, reference string) (bool, error) // Checks if a transaction exists by reference
53 GetExistingTransactionReferences(ctx context.Context, references []string) (map[string]struct{}, error) // Gets existing transaction references in bulk
54 UpdateTransactionStatus(cxt context.Context, id string, status string) error // Updates the status of a transaction
55 GetAllTransactions(cxt context.Context, limit, offset int) ([]model.Transaction, error) // Retrieves all transactions
56 GetTotalCommittedTransactions(cxt context.Context, parentID string) (*big.Int, error) // Gets the total count of committed transactions for a parent
57 GetTransactionsPaginated(ctx context.Context, id string, batchSize int, offset int64) ([]*model.Transaction, error) // Retrieves transactions in a paginated manner
58 GetInflightTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error) // Retrieves inflight transactions by parent ID
59 GetRefundableTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error) // Retrieves refundable transactions by parent ID
60 GroupTransactions(ctx context.Context, groupCriteria string, batchSize int, offset int64) (map[string][]*model.Transaction, error) // Groups transactions based on specified criteria
61 UpdateLedgerMetadata(id string, metadata map[string]interface{}) error
62 UpdateTransactionMetadata(ctx context.Context, id string, metadata map[string]interface{}) error
63 UpdateBalanceMetadata(ctx context.Context, id string, metadata map[string]interface{}) error
64 UpdateIdentityMetadata(id string, metadata map[string]interface{}) error
65 TransactionExistsByIDOrParentID(ctx context.Context, id string) (bool, error)
66 GetTransactionsByParent(ctx context.Context, parentID string, limit int, offset int64) ([]*model.Transaction, error) // Retrieves transactions by parent ID with pagination
67 IsTransactionRefunded(ctx context.Context, transaction *model.Transaction) (bool, error) // Checks if a transaction has already been refunded
68 GetTransactionsByCriteria(ctx context.Context, minAmount, maxAmount *float64, currency *string, minDate, maxDate *time.Time, limit int, offset int64) ([]*model.Transaction, error)
69 GetTransactionsByShadowFor(ctx context.Context, parentTransactionID string) ([]model.Transaction, error) // Retrieves shadow transactions by parent transaction ID
70 GetStuckQueuedTransactions(ctx context.Context, threshold time.Duration, batchSize int) ([]*model.Transaction, error) // Retrieves stuck QUEUED transactions with no child
71 GetQueuedTransactionsForCoalescing(ctx context.Context, source, destination, currency, excludeTransactionID string, createdAtOrAfter time.Time, limit int) ([]*model.Transaction, error)
72 GetQueuedTransactionsForSourceCoalescing(ctx context.Context, source, currency, excludeTransactionID string, createdAtOrAfter time.Time, limit int) ([]*model.Transaction, error)
73 GetQueuedTransactionsForDestinationCoalescing(ctx context.Context, destination, currency, excludeTransactionID string, createdAtOrAfter time.Time, limit int) ([]*model.Transaction, error)
74 CountQueuedTransactionsForPairLane(ctx context.Context, source, destination, currency, lane string) (int, error)
75
76 // Advanced filtering methods
77 GetAllTransactionsWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Transaction, error) // Retrieves transactions with advanced filtering
78 GetAllTransactionsWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, limit, offset int) ([]model.Transaction, *int64, error) // Retrieves transactions with filtering, sorting, and count
79}
80
81// ledger defines methods for handling ledgers.
82type ledger interface {

Implementers 2

Datasourcedatabase/db.go
MockDataSourcedatabase/mocks/repo_mocks.go

Calls

no outgoing calls

Tested by

no test coverage detected