Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve transaction metadata initialization and reference formatting #79

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1424,17 +1424,17 @@ func setTransactionStatus(transaction *model.Transaction) {
}

// setTransactionMetadata initializes and sets the required metadata for a transaction.
// It sets the skip balance update flag, creation time, generates a new transaction ID,
// calculates the transaction hash, and sets the precise amount based on the transaction's precision.
//
// Parameters:
// - transaction *model.Transaction: The transaction for which to set metadata.
func setTransactionMetadata(transaction *model.Transaction) {
transaction.SkipBalanceUpdate = true
transaction.CreatedAt = time.Now()
transaction.TransactionID = model.GenerateUUIDWithSuffix("txn")
transaction.Hash = transaction.HashTxn()
transaction.PreciseAmount = int64(transaction.Amount * transaction.Precision)
if transaction.TransactionID == "" {
transaction.TransactionID = model.GenerateUUIDWithSuffix("txn")
}
}

// createQueueCopy creates a new copy of a transaction specifically for queueing.
Expand Down Expand Up @@ -1464,7 +1464,7 @@ func createQueueCopy(persistedTxn *model.Transaction, originalRef string) *model
func updateSplitTransactions(transactions []*model.Transaction, parentID, originalRef string) {
for i, txn := range transactions {
txn.ParentTransaction = parentID
txn.Reference = fmt.Sprintf("%s_q%d", originalRef, i+1)
txn.Reference = fmt.Sprintf("%s_%d", originalRef, i+1)
}
}

Expand Down
Loading