OSDN Git Service

Removed validate.config. and Modified config.
[bytom/bytom.git] / cmd / bytom / commands / init.go
1 package commands
2
3 import (
4         "os"
5
6         "github.com/spf13/cobra"
7
8         "github.com/bytom/types"
9         cmn "github.com/tendermint/tmlibs/common"
10 )
11
12 var initFilesCmd = &cobra.Command {
13         Use:   "init",
14         Short: "Initialize blockchain",
15         Run:   initFiles,
16 }
17
18 func init() {
19         RootCmd.AddCommand(initFilesCmd)
20 }
21
22 func initFiles(cmd *cobra.Command, args []string) {
23         genFile := config.GenesisFile()
24
25         if _, err := os.Stat(genFile); os.IsNotExist(err) {
26                 genDoc := types.GenesisDoc{
27                         ChainID: cmn.Fmt("bytom"),
28                 }
29
30                 genDoc.SaveAs(genFile)
31         }
32
33         logger.Info("Initialized bytom", "genesis", config.GenesisFile())
34 }