From 546c7d7d65a33710823ba5321a5abbb9729e308e Mon Sep 17 00:00:00 2001 From: Andres Babino Date: Wed, 9 Oct 2024 05:42:45 -0300 Subject: [PATCH] fix lint issues --- cmd/core/bid-adjustments-backfill.go | 12 +++++----- common/ultrasoundbid.go | 16 +++++++------- .../005_create_adjustments_table.go | 3 +-- .../006_add_slot_index_to_bid_adjustments.go | 1 - database/types.go | 22 +++++++++---------- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/cmd/core/bid-adjustments-backfill.go b/cmd/core/bid-adjustments-backfill.go index 8955b6e..cea4264 100644 --- a/cmd/core/bid-adjustments-backfill.go +++ b/cmd/core/bid-adjustments-backfill.go @@ -13,9 +13,7 @@ import ( "github.com/spf13/cobra" ) -var ( - bidAdjustmentRelay string -) +var bidAdjustmentRelay string func init() { bidAdjustmentsBackfillCmd.Flags().StringVar(&bidAdjustmentRelay, "relay", "relay.ultrasound.money", "relay to fetch bid adjustments from") @@ -84,10 +82,12 @@ func (bf *bidAdjustmentsBackfiller) backfillAdjustments() error { } // Hardcoded ultrasoiund first slot with data see https://github.com/ultrasoundmoney/docs/blob/main/bid_adjustment.md#data-api - if bf.minSlot < 7869470 { - bf.minSlot = 7869470 + const ultrasoundFirstBidAdjustmentSlot = 7869470 + if bf.minSlot < ultrasoundFirstBidAdjustmentSlot { + bf.minSlot = ultrasoundFirstBidAdjustmentSlot } + const ultrasoundEndStatusCode = 403 for slot := bf.minSlot; ; slot++ { _log.WithField("slot", slot).Info("Fetching adjustments...") url := fmt.Sprintf("%s?slot=%d", baseURL, slot) @@ -95,7 +95,7 @@ func (bf *bidAdjustmentsBackfiller) backfillAdjustments() error { var response common.UltrasoundAdjustmentResponse statusCode, err := common.SendHTTPRequest(context.Background(), *http.DefaultClient, http.MethodGet, url, nil, &response) _log.WithField("status code", statusCode).Info("Response") - if statusCode == 403 { + if statusCode == ultrasoundEndStatusCode { _log.WithField("Status Code", statusCode).Info("Stopping backfill due to 403") break } diff --git a/common/ultrasoundbid.go b/common/ultrasoundbid.go index 36422eb..0c40de7 100644 --- a/common/ultrasoundbid.go +++ b/common/ultrasoundbid.go @@ -32,12 +32,12 @@ type UltrasoundAdjustmentResponse struct { } type UltrasoundAdjustment struct { - AdjustedBlockHash string `json:"adjusted_block_hash"` - AdjustedValue string `json:"adjusted_value"` - BlockNumber uint64 `json:"block_number"` - BuilderPubkey string `json:"builder_pubkey"` - Delta string `json:"delta"` - SubmittedBlockHash string `json:"submitted_block_hash"` - SubmittedReceivedAt string `json:"submitted_received_at"` - SubmittedValue string `json:"submitted_value"` + AdjustedBlockHash string `json:"adjusted_block_hash"` + AdjustedValue string `json:"adjusted_value"` + BlockNumber uint64 `json:"block_number"` + BuilderPubkey string `json:"builder_pubkey"` + Delta string `json:"delta"` + SubmittedBlockHash string `json:"submitted_block_hash"` + SubmittedReceivedAt string `json:"submitted_received_at"` + SubmittedValue string `json:"submitted_value"` } diff --git a/database/migrations/005_create_adjustments_table.go b/database/migrations/005_create_adjustments_table.go index f31f784..8403d8a 100644 --- a/database/migrations/005_create_adjustments_table.go +++ b/database/migrations/005_create_adjustments_table.go @@ -5,7 +5,7 @@ import ( migrate "github.com/rubenv/sql-migrate" ) -var migration005SQL = `CREATE TABLE IF NOT EXISTS ` + vars.TableAdjustments +` ( +var migration005SQL = `CREATE TABLE IF NOT EXISTS ` + vars.TableAdjustments + ` ( id SERIAL PRIMARY KEY, inserted_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), slot BIGINT NOT NULL, @@ -20,7 +20,6 @@ var migration005SQL = `CREATE TABLE IF NOT EXISTS ` + vars.TableAdjustments +` ( UNIQUE(slot, adjusted_block_hash) );` - var Migration005CreateAdjustmentsTable = &migrate.Migration{ Id: "005-create-adjustments-table", Up: []string{migration005SQL}, diff --git a/database/migrations/006_add_slot_index_to_bid_adjustments.go b/database/migrations/006_add_slot_index_to_bid_adjustments.go index 88e0b4b..5e6ae61 100644 --- a/database/migrations/006_add_slot_index_to_bid_adjustments.go +++ b/database/migrations/006_add_slot_index_to_bid_adjustments.go @@ -14,4 +14,3 @@ var Migration006AddSlotIndexToAdjustments = &migrate.Migration{ DisableTransactionUp: false, DisableTransactionDown: true, } - diff --git a/database/types.go b/database/types.go index c160839..3837d15 100644 --- a/database/types.go +++ b/database/types.go @@ -197,15 +197,15 @@ type TmpPayloadsForExtraDataEntry struct { } type AdjustmentEntry struct { - ID int64 `db:"id"` - InsertedAt time.Time `db:"inserted_at"` - Slot uint64 `db:"slot"` - AdjustedBlockHash string `db:"adjusted_block_hash"` - AdjustedValue string `db:"adjusted_value"` - BlockNumber uint64 `db:"block_number"` - BuilderPubkey string `db:"builder_pubkey"` - Delta string `db:"delta"` - SubmittedBlockHash string `db:"submitted_block_hash"` - SubmittedReceivedAt time.Time `db:"submitted_received_at"` - SubmittedValue string `db:"submitted_value"` + ID int64 `db:"id"` + InsertedAt time.Time `db:"inserted_at"` + Slot uint64 `db:"slot"` + AdjustedBlockHash string `db:"adjusted_block_hash"` + AdjustedValue string `db:"adjusted_value"` + BlockNumber uint64 `db:"block_number"` + BuilderPubkey string `db:"builder_pubkey"` + Delta string `db:"delta"` + SubmittedBlockHash string `db:"submitted_block_hash"` + SubmittedReceivedAt time.Time `db:"submitted_received_at"` + SubmittedValue string `db:"submitted_value"` }