From a3828ecf1ace0cba8c5dae44cae26209d02f810a Mon Sep 17 00:00:00 2001 From: Hemanth Sai Date: Wed, 20 Dec 2023 15:05:37 +0530 Subject: [PATCH] fix(server): fix backend issue (#992) fix(backend): fix backend issues --- server/handler/transactions.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/handler/transactions.go b/server/handler/transactions.go index af35aeefa..529f24521 100644 --- a/server/handler/transactions.go +++ b/server/handler/transactions.go @@ -104,7 +104,6 @@ func (h *Handler) GetTransactions(c echo.Context) error { status := utils.GetStatus(c.QueryParam("status")) var rows *sql.Rows - defer rows.Close() if status == model.Pending { rows, err = h.DB.Query(`SELECT t.id,t.multisig_address,t.status,t.created_at,t.last_updated,t.memo,t.signatures,t.messages,t.hash,t.err_msg,t.fee, m.threshold, json_agg(jsonb_build_object('pubkey', p.pubkey, 'address', p.address, 'multisig_address',p.multisig_address)) AS pubkeys FROM transactions t JOIN multisig_accounts m ON t.multisig_address = m.address JOIN pubkeys p ON t.multisig_address = p.multisig_address WHERE t.multisig_address=$1 and t.status='PENDING' GROUP BY t.id, t.multisig_address, m.threshold, t.messages LIMIT $2 OFFSET $3`, @@ -129,6 +128,7 @@ func (h *Handler) GetTransactions(c echo.Context) error { Log: err.Error(), }) } + defer rows.Close() transactions := make([]schema.AllTransactionResult, 0) for rows.Next() { @@ -156,7 +156,6 @@ func (h *Handler) GetTransactions(c echo.Context) error { } transactions = append(transactions, transaction) } - rows.Close() return c.JSON(http.StatusOK, model.SuccessResponse{ Data: transactions, @@ -181,7 +180,6 @@ func (h *Handler) GetAllMultisigTxns(c echo.Context) error { Log: err.Error(), }) } - defer multisigRows.Close() transactions := make([]schema.AllTransactionResult, 0) @@ -196,7 +194,6 @@ func (h *Handler) GetAllMultisigTxns(c echo.Context) error { } var rows *sql.Rows - defer rows.Close() if status == "PENDING" { rows, err = h.DB.Query(`SELECT t.id,t.multisig_address,t.status,t.created_at,t.last_updated,t.memo,t.signatures,t.messages,t.hash,t.err_msg,t.fee, m.threshold, json_agg(jsonb_build_object('pubkey', p.pubkey, 'address', p.address, 'multisig_address',p.multisig_address)) AS pubkeys FROM transactions t JOIN multisig_accounts m ON t.multisig_address = m.address JOIN pubkeys p ON t.multisig_address = p.multisig_address WHERE t.multisig_address=$1 and t.status='PENDING' GROUP BY t.id, t.multisig_address, m.threshold, t.messages LIMIT $2 OFFSET $3`, @@ -249,6 +246,7 @@ func (h *Handler) GetAllMultisigTxns(c echo.Context) error { } rows.Close() } + defer multisigRows.Close() return c.JSON(http.StatusOK, model.SuccessResponse{ Data: transactions,