commit c11e29d793fdc1c2871938b9734d54752dc7509d
parent 763e4be4a15815ab061187f7da01e7d296498c17
Author: Joel-Haeberli <haebu@rubigen.ch>
Date: Mon, 3 Jun 2024 17:56:19 +0200
fix: db query
Diffstat:
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/c2ec/api-wire-gateway.go b/c2ec/api-wire-gateway.go
@@ -219,6 +219,7 @@ func transfer(res http.ResponseWriter, req *http.Request) {
transfer.ExchangeBaseUrl,
string(transfer.Wtid),
transfer.CreditAccount,
+ time.Now(),
)
if err != nil {
LogWarn("wire-gateway-api", "failed adding new transfer entry to database")
diff --git a/c2ec/db-postgres.go b/c2ec/db-postgres.go
@@ -84,7 +84,8 @@ const PS_GET_TRANSFER_BY_ID = "SELECT * FROM " + TRANSFER_TABLE_NAME +
const PS_ADD_TRANSFER = "INSERT INTO " + TRANSFER_TABLE_NAME +
" (" + TRANSFER_FIELD_NAME_ID + ", " + TRANSFER_FIELD_NAME_AMOUNT + ", " +
TRANSFER_FIELD_NAME_EXCHANGE_BASE_URL + ", " + TRANSFER_FIELD_NAME_WTID + ", " +
- TRANSFER_FIELD_NAME_CREDIT_ACCOUNT + ") VALUES ($1, $2, $3, $4, $5)"
+ TRANSFER_FIELD_NAME_CREDIT_ACCOUNT + ", " + TRANSFER_FIELD_NAME_TS +
+ ") VALUES ($1,$2,$3,$4,$5,$6)"
const PS_UPDATE_TRANSFER = "UPDATE " + TRANSFER_TABLE_NAME + " SET (" +
TRANSFER_FIELD_NAME_TS + ", " + TRANSFER_FIELD_NAME_STATUS + ", " +
@@ -714,6 +715,7 @@ func (db *C2ECPostgres) AddTransfer(
exchangeBaseUrl string,
wtid string,
credit_account string,
+ ts time.Time,
) error {
dbAmount := TalerAmountCurrency{
@@ -722,7 +724,7 @@ func (db *C2ECPostgres) AddTransfer(
Curr: amount.Currency,
}
- res, err := db.pool.Query(
+ _, err := db.pool.Exec(
db.ctx,
PS_ADD_TRANSFER,
requestUid,
@@ -730,12 +732,12 @@ func (db *C2ECPostgres) AddTransfer(
exchangeBaseUrl,
wtid,
credit_account,
+ ts.Unix(),
)
if err != nil {
LogError("postgres", err)
return err
}
- res.Close()
LogInfo("postgres", "query="+PS_ADD_TRANSFER)
return nil
}
diff --git a/c2ec/db.go b/c2ec/db.go
@@ -203,6 +203,7 @@ type C2ECDatabase interface {
exchangeBaseUrl string,
wtid string,
credit_account string,
+ ts time.Time,
) error
// Updates the transfer, if retries is changed, the transfer will be