From 3f907495a20767a9485ac5753247a6500c25e703 Mon Sep 17 00:00:00 2001 From: sczembor Date: Thu, 19 Dec 2024 15:44:53 +0100 Subject: [PATCH] fix linter Signed-off-by: sczembor --- dal/daltest/helpers.go | 12 +++++++---- dal/db.go | 47 +++++++++++++++++++++++++++++++++++++----- nbtc/relayer.go | 8 ++++++- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/dal/daltest/helpers.go b/dal/daltest/helpers.go index ec4e238..3d1d423 100644 --- a/dal/daltest/helpers.go +++ b/dal/daltest/helpers.go @@ -46,10 +46,14 @@ func PopulateSignRequests(t *testing.T, db *dal.DB) []dal.IkaSignRequest { } requests := []dal.IkaSignRequest{ - {ID: 1, Payload: rawTxBytes, DWalletID: "dwallet1", UserSig: "user_sig1", FinalSig: nil, Timestamp: time.Now().Unix()}, - {ID: 2, Payload: rawTxBytes, DWalletID: "dwallet2", UserSig: "user_sig2", FinalSig: []byte("final_sig2"), Timestamp: time.Now().Unix()}, - {ID: 3, Payload: rawTxBytes, DWalletID: "dwallet3", UserSig: "user_sig3", FinalSig: nil, Timestamp: time.Now().Unix()}, - {ID: 4, Payload: rawTxBytes, DWalletID: "dwallet4", UserSig: "user_sig4", FinalSig: []byte("final_sig4"), Timestamp: time.Now().Unix()}, + {ID: 1, Payload: rawTxBytes, DWalletID: "dwallet1", + UserSig: "user_sig1", FinalSig: nil, Timestamp: time.Now().Unix()}, + {ID: 2, Payload: rawTxBytes, DWalletID: "dwallet2", + UserSig: "user_sig2", FinalSig: []byte("final_sig2"), Timestamp: time.Now().Unix()}, + {ID: 3, Payload: rawTxBytes, DWalletID: "dwallet3", + UserSig: "user_sig3", FinalSig: nil, Timestamp: time.Now().Unix()}, + {ID: 4, Payload: rawTxBytes, DWalletID: "dwallet4", + UserSig: "user_sig4", FinalSig: []byte("final_sig4"), Timestamp: time.Now().Unix()}, } for _, request := range requests { diff --git a/dal/db.go b/dal/db.go index fd5be0c..27ef7d9 100644 --- a/dal/db.go +++ b/dal/db.go @@ -138,7 +138,15 @@ func (db *DB) InsertIkaSignRequest(signReq IkaSignRequest) error { const insertIkaSignRequestSQL = ` INSERT INTO ika_sign_requests (id, payload, dwallet_id, user_sig, final_sig, timestamp) VALUES (?, ?, ?, ?, ?, ?)` - _, err := db.conn.Exec(insertIkaSignRequestSQL, signReq.ID, signReq.Payload, signReq.DWalletID, signReq.UserSig, signReq.FinalSig, signReq.Timestamp) + _, err := db.conn.Exec( + insertIkaSignRequestSQL, + signReq.ID, + signReq.Payload, + signReq.DWalletID, + signReq.UserSig, + signReq.FinalSig, + signReq.Timestamp, + ) return err } @@ -168,7 +176,14 @@ func (db DB) GetIkaSignRequestByID(id uint64) (*IkaSignRequest, error) { WHERE id = ?` row := db.conn.QueryRow(getIkaSignRequestByIDSQL, id) var signReq IkaSignRequest - err := row.Scan(&signReq.ID, &signReq.Payload, &signReq.DWalletID, &signReq.UserSig, &signReq.FinalSig, &signReq.Timestamp) + err := row.Scan( + &signReq.ID, + &signReq.Payload, + &signReq.DWalletID, + &signReq.UserSig, + &signReq.FinalSig, + &signReq.Timestamp, + ) if err != nil { if err == sql.ErrNoRows { return nil, nil @@ -229,7 +244,15 @@ func (db *DB) GetIkaSignRequestWithStatus(id uint64) (*IkaSignRequest, IkaTxStat row := db.conn.QueryRow(getIkaSignRequestWithStatusSQL, id) var request IkaSignRequest var status IkaTxStatus - err := row.Scan(&request.ID, &request.Payload, &request.DWalletID, &request.UserSig, &request.FinalSig, &request.Timestamp, &status) + err := row.Scan( + &request.ID, + &request.Payload, + &request.DWalletID, + &request.UserSig, + &request.FinalSig, + &request.Timestamp, + &status, + ) if err != nil { if err == sql.ErrNoRows { return nil, 0, nil @@ -258,7 +281,14 @@ func (db *DB) GetSignedIkaSignRequests() ([]IkaSignRequest, error) { var requests []IkaSignRequest for rows.Next() { var request IkaSignRequest - err := rows.Scan(&request.ID, &request.Payload, &request.DWalletID, &request.UserSig, &request.FinalSig, &request.Timestamp) + err := rows.Scan( + &request.ID, + &request.Payload, + &request.DWalletID, + &request.UserSig, + &request.FinalSig, + &request.Timestamp, + ) if err != nil { return nil, fmt.Errorf("failed to scan row: %w", err) } @@ -313,7 +343,14 @@ func (db *DB) GetPendingIkaSignRequests() ([]IkaSignRequest, error) { var requests []IkaSignRequest for rows.Next() { var request IkaSignRequest - err := rows.Scan(&request.ID, &request.Payload, &request.DWalletID, &request.UserSig, &request.FinalSig, &request.Timestamp) + err := rows.Scan( + &request.ID, + &request.Payload, + &request.DWalletID, + &request.UserSig, + &request.FinalSig, + &request.Timestamp, + ) if err != nil { return nil, fmt.Errorf("failed to scan row: %w", err) } diff --git a/nbtc/relayer.go b/nbtc/relayer.go index e37bb70..479a97d 100644 --- a/nbtc/relayer.go +++ b/nbtc/relayer.go @@ -134,7 +134,13 @@ func (r *Relayer) processSignedTxs() error { } // TODO: add failed broadcasting to the bitcoinTx table with notes about the error - err = r.db.InsertBtcTx(dal.BitcoinTx{TxID: tx.ID, Status: dal.Broadcasted, BtcTxID: txHash.CloneBytes(), Timestamp: time.Now().Unix(), Note: ""}) + err = r.db.InsertBtcTx(dal.BitcoinTx{ + TxID: tx.ID, + Status: dal.Broadcasted, + BtcTxID: txHash.CloneBytes(), + Timestamp: time.Now().Unix(), + Note: "", + }) if err != nil { return fmt.Errorf("DB: can't update tx status: %w", err) }