Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #46 from spacemeshos/fix-post-json
Browse files Browse the repository at this point in the history
Output correct post json to file (WIP)
  • Loading branch information
avive authored Aug 4, 2021
2 parents 7f4eb5a + 39ed68f commit e4b158e
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions repl/smesher_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package repl

import (
"encoding/hex"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"strconv"
"strings"

"github.com/spacemeshos/smrepl/common"

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e4b158e

Please sign in to comment.