diff --git a/repl/smesher_commands.go b/repl/smesher_commands.go index d4f9090..c46e24b 100644 --- a/repl/smesher_commands.go +++ b/repl/smesher_commands.go @@ -2,11 +2,11 @@ package repl import ( "encoding/hex" - "encoding/json" "fmt" "io" "io/ioutil" "strconv" + "strings" "github.com/spacemeshos/smrepl/common" @@ -239,24 +239,27 @@ func (r *repl) setupPos() { fmt.Println("👐 Proof of spacetime setup has started and your node will start smeshing when it is complete.") fmt.Println("⚠️ IMPORTANT: Please update the smeshing section of your node's config file with the following so your node will smesh after you restart it.") fmt.Println() - fmt.Println("\"smeshing:\" {") - fmt.Println("\"\tsmeshing-start\": true,") - fmt.Printf("\"\tsmeshing-coinbase\": \"%s\"\n", addrStr) - fmt.Println("\"\tsmeshing-opts:\" {") - - fmt.Printf("\t\t\"smeshing-opts-datadir\": \"%s\",\n", dataDir) - fmt.Printf("\t\t\"smeshing-opts-numunits\": \"%d\",\n", numUnits) - fmt.Printf("\t\t\"smeshing-opts-numfiles\": \"%d\",\n", 1) - fmt.Printf("\t\t\"smeshing-opts-provider\": \"%d\",\n", providerId) - fmt.Println("\t\t\"smeshing-opts-throttle\": \"true\",") - fmt.Println("\t},") - fmt.Println("},") - fmt.Println() - // save pos options in pos.json in cli-wallet directory: - data, _ := json.MarshalIndent(req.Opts, "", " ") + var builder strings.Builder + _, _ = fmt.Fprintln(&builder, "{") + _, _ = fmt.Fprintln(&builder, "\t\"smeshing\": {") + _, _ = fmt.Fprintln(&builder, "\t\t\"smeshing-start\": true,") + _, _ = fmt.Fprintf(&builder, "\t\t\"smeshing-coinbase\": \"%s\"\n", addrStr) + + _, _ = fmt.Fprintf(&builder, "\t\t\"smeshing-opts:\" {\n") + _, _ = fmt.Fprintf(&builder, "\t\t\t\"smeshing-opts-datadir\": \"%s\",\n", dataDir) + _, _ = fmt.Fprintf(&builder, "\t\t\t\"smeshing-opts-numunits\": %d,\n", numUnits) + _, _ = fmt.Fprintf(&builder, "\t\t\t\"smeshing-opts-numfiles\": %d,\n", 1) + _, _ = fmt.Fprintf(&builder, "\t\t\t\"smeshing-opts-provider\": %d,\n", providerId) + _, _ = fmt.Fprintf(&builder, "\t\t\t\"smeshing-opts-throttle\": true\n") + _, _ = fmt.Fprintf(&builder, "\t\t}\n") + _, _ = fmt.Fprintf(&builder, "\t}\n") + _, _ = fmt.Fprintf(&builder, "}\n") + + fmt.Println(builder.String()) + + err = ioutil.WriteFile(posDataFileName, []byte(builder.String()), 0644) - err = ioutil.WriteFile(posDataFileName, data, 0644) if err == nil { fmt.Printf("Proof of spacetime seup options saved to %s.\n\n", posDataFileName) } else {