Browse Source

Pretty print JSON

pull/206/merge
Jae Kwon 9 years ago
parent
commit
9b4b533f2f
4 changed files with 6 additions and 7 deletions
  1. +2
    -2
      cmd/tendermint/gen_validator.go
  2. +2
    -3
      cmd/tendermint/show_validator.go
  3. +1
    -1
      types/genesis.go
  4. +1
    -1
      types/priv_validator.go

+ 2
- 2
cmd/tendermint/gen_validator.go View File

@ -3,14 +3,14 @@ package main
import (
"fmt"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/types"
)
func gen_validator() {
privValidator := types.GenPrivValidator()
privValidatorJSONBytes := wire.JSONBytes(privValidator)
privValidatorJSONBytes := wire.JSONBytesPretty(privValidator)
fmt.Printf(`Generated a new validator!
Paste the following JSON into your %v file


+ 2
- 3
cmd/tendermint/show_validator.go View File

@ -1,15 +1,14 @@
package main
import (
"fmt"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/go-wire"
"github.com/tendermint/tendermint/types"
)
func show_validator() {
privValidatorFile := config.GetString("priv_validator_file")
privValidator := types.LoadOrGenPrivValidator(privValidatorFile)
fmt.Println(string(wire.JSONBytes(privValidator.PubKey)))
fmt.Println(string(wire.JSONBytesPretty(privValidator.PubKey)))
}

+ 1
- 1
types/genesis.go View File

@ -31,7 +31,7 @@ type GenesisDoc struct {
// Utility method for saving GenensisDoc as JSON file.
func (genDoc *GenesisDoc) SaveAs(file string) error {
genDocBytes := wire.JSONBytes(genDoc)
genDocBytes := wire.JSONBytesPretty(genDoc)
return WriteFile(file, genDocBytes, 0644)
}


+ 1
- 1
types/priv_validator.go View File

@ -141,7 +141,7 @@ func (privVal *PrivValidator) save() {
if privVal.filePath == "" {
PanicSanity("Cannot save PrivValidator: filePath not set")
}
jsonBytes := wire.JSONBytes(privVal)
jsonBytes := wire.JSONBytesPretty(privVal)
err := WriteFileAtomic(privVal.filePath, jsonBytes, 0600)
if err != nil {
// `@; BOOM!!!


Loading…
Cancel
Save