Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions cmd/mithril/configcmd/configcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package configcmd
import (
"bufio"
"fmt"
"math"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -117,9 +118,7 @@ func runConfigInit() {
}

func generateStarterConfig() string {
// Pick storage paths that work for the current environment: production
// /mnt/mithril-* when scripts/disk-setup.sh has been run, ~/.mithril/*
// otherwise. See pkg/config/defaults.go for detection details.
// Storage paths default to /mnt/mithril-* or ~/.mithril/*; see pkg/config/defaults.go.
s := config.DefaultStoragePaths()
return fmt.Sprintf(`# Mithril Configuration
# Generated by: mithril config init
Expand Down Expand Up @@ -155,7 +154,10 @@ source = "rpc" # "rpc" | "lightbringer" | "turbine"
# [lightbringer]
# enabled = false
# binary_path = "./lightbringer"
# gossip_entrypoint = "1.2.3.4:8000"
# gossip_entrypoint = "entrypoint.mainnet-beta.solana.com:8001"
# gossip_port = 65400 # Public Solana gossip UDP port
# port_range_start = 65401 # Public Solana repair/TVU UDP range
# port_range_end = 65500
# shredstore stored in [storage] section
# rpc_addr = "127.0.0.1:3000"
# grpc_addr = "127.0.0.1:3001"
Expand Down Expand Up @@ -302,10 +304,13 @@ func formatTOMLValue(value string) string {
if _, err := fmt.Sscanf(value, "%d", &n); err == nil && fmt.Sprintf("%d", n) == strings.TrimSpace(value) {
return fmt.Sprintf("%d", n)
}
// Check if it's a float — return the parsed number, not raw input
var f float64
if _, err := fmt.Sscanf(value, "%f", &f); err == nil && !strings.ContainsAny(value, "\n\r") {
return strconv.FormatFloat(f, 'f', -1, 64)
// Float only if it parses whole and round-trips (keeps IPs/versions as strings).
if t := strings.TrimSpace(value); t != "" {
if f, err := strconv.ParseFloat(t, 64); err == nil && !math.IsInf(f, 0) && !math.IsNaN(f) {
if canon := strconv.FormatFloat(f, 'f', -1, 64); canon == t {
return canon
}
}
}

// Check if it's a boolean
Expand Down
Loading
Loading