Skip to content

Commit

Permalink
sql: insert empty v2_settings in UpdateHost
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Nov 15, 2024
1 parent 0d20bc4 commit 5e8c249
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion stores/sql/mysql/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (c chainUpdateTx) UpdateHost(hk types.PublicKey, v1Addr string, v2Ha chain.
// create the host
var hostID int64
if res, err := c.tx.Exec(c.ctx, `
INSERT INTO hosts (created_at, public_key, settings, price_table, total_scans, last_scan, last_scan_success, second_to_last_scan_success, scanned, uptime, downtime, recent_downtime, recent_scan_failures, successful_interactions, failed_interactions, lost_sectors, last_announcement, net_address)
INSERT INTO hosts (created_at, public_key, settings, v2_settings, price_table, total_scans, last_scan, last_scan_success, second_to_last_scan_success, scanned, uptime, downtime, recent_downtime, recent_scan_failures, successful_interactions, failed_interactions, lost_sectors, last_announcement, net_address)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
last_announcement = VALUES(last_announcement),
Expand All @@ -220,6 +220,7 @@ func (c chainUpdateTx) UpdateHost(hk types.PublicKey, v1Addr string, v2Ha chain.
time.Now().UTC(),
ssql.PublicKey(hk),
ssql.HostSettings{},
ssql.V2HostSettings{},
ssql.PriceTable{},
0,
0,
Expand Down
3 changes: 2 additions & 1 deletion stores/sql/sqlite/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (c chainUpdateTx) UpdateHost(hk types.PublicKey, v1Addr string, v2Ha chain.
// create the host
var hostID int64
if err := c.tx.QueryRow(c.ctx, `
INSERT INTO hosts (created_at, public_key, settings, price_table, total_scans, last_scan, last_scan_success, second_to_last_scan_success, scanned, uptime, downtime, recent_downtime, recent_scan_failures, successful_interactions, failed_interactions, lost_sectors, last_announcement, net_address)
INSERT INTO hosts (created_at, public_key, settings, v2_settings, price_table, total_scans, last_scan, last_scan_success, second_to_last_scan_success, scanned, uptime, downtime, recent_downtime, recent_scan_failures, successful_interactions, failed_interactions, lost_sectors, last_announcement, net_address)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(public_key) DO UPDATE SET
last_announcement = EXCLUDED.last_announcement,
Expand All @@ -222,6 +222,7 @@ func (c chainUpdateTx) UpdateHost(hk types.PublicKey, v1Addr string, v2Ha chain.
time.Now().UTC(),
ssql.PublicKey(hk),
ssql.HostSettings{},
ssql.V2HostSettings{},
ssql.PriceTable{},
0,
0,
Expand Down
2 changes: 1 addition & 1 deletion stores/sql/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ func (hs *V2HostSettings) Scan(value interface{}) error {
case []byte:
bytes = value
default:
return errors.New(fmt.Sprint("failed to unmarshal Settings value:", value))
return errors.New(fmt.Sprint("failed to unmarshal V2Settings value:", value))
}
return json.Unmarshal(bytes, hs)
}
Expand Down

0 comments on commit 5e8c249

Please sign in to comment.