Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ababino committed Oct 9, 2024
1 parent 88dde5b commit 546c7d7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
12 changes: 6 additions & 6 deletions cmd/core/bid-adjustments-backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -84,18 +82,20 @@ 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)

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
}
Expand Down
16 changes: 8 additions & 8 deletions common/ultrasoundbid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
3 changes: 1 addition & 2 deletions database/migrations/005_create_adjustments_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ var Migration006AddSlotIndexToAdjustments = &migrate.Migration{
DisableTransactionUp: false,
DisableTransactionDown: true,
}

22 changes: 11 additions & 11 deletions database/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit 546c7d7

Please sign in to comment.