Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
Signed-off-by: sczembor <[email protected]>
  • Loading branch information
sczembor committed Dec 19, 2024
1 parent e1895a7 commit 3f90749
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
12 changes: 8 additions & 4 deletions dal/daltest/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
47 changes: 42 additions & 5 deletions dal/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 7 additions & 1 deletion nbtc/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 3f90749

Please sign in to comment.