Skip to content

Commit

Permalink
encode transaction IDs before passing to DB
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 committed Jan 12, 2024
1 parent 832e9aa commit fcefea8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion persist/sqlite/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,16 @@ func blockMinerPayouts(tx txn, blockID types.BlockID) ([]types.SiacoinOutput, er

// transactionDatabaseIDs returns the database ID for each transaction.
func transactionDatabaseIDs(tx txn, txnIDs []types.TransactionID) (dbIDs []int64, err error) {
encodedIDs := func(ids []types.TransactionID) []any {
result := make([]any, len(ids))
for i, id := range ids {
result[i] = dbEncode(id)
}
return result
}

query := `SELECT id FROM transactions WHERE transaction_id IN (` + queryPlaceHolders(len(txnIDs)) + `)`
rows, err := tx.Query(query, queryArgs(txnIDs)...)
rows, err := tx.Query(query, encodedIDs(txnIDs)...)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit fcefea8

Please sign in to comment.