Clean up seed input/output code
This commit is contained in:
parent
f967c1dc07
commit
2ac564fead
|
@ -1,15 +1,11 @@
|
|||
package seeds
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/commands"
|
||||
"github.com/tendermint/light-client/certifiers"
|
||||
)
|
||||
|
||||
var exportCmd = &cobra.Command{
|
||||
|
@ -44,17 +40,5 @@ func exportSeed(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
// now get the output file and write it
|
||||
return writeSeed(seed, path)
|
||||
}
|
||||
|
||||
// TODO use certifiers function
|
||||
func writeSeed(seed certifiers.Seed, path string) (err error) {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
defer f.Close()
|
||||
stream := json.NewEncoder(f)
|
||||
err = stream.Encode(seed)
|
||||
return errors.WithStack(err)
|
||||
return seed.WriteJSON(path)
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func importSeed(cmd *cobra.Command, args []string) error {
|
|||
|
||||
// parse the input file
|
||||
path := args[0]
|
||||
seed, err := certifiers.LoadSeed(path)
|
||||
seed, err := certifiers.LoadSeedJSON(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ func loadSeed(p certifiers.Provider, h int, hash, file string) (seed certifiers.
|
|||
seed, err = p.GetByHash(vhash)
|
||||
}
|
||||
} else if file != "" {
|
||||
seed, err = certifiers.LoadSeed(file)
|
||||
seed, err = certifiers.LoadSeedJSON(file)
|
||||
} else {
|
||||
// default is latest seed
|
||||
seed, err = certifiers.LatestSeed(p)
|
||||
|
|
Loading…
Reference in New Issue