generate node_key when running tendermint init

This commit is contained in:
Anton Kaliaev 2018-04-09 15:41:26 +02:00
parent dcd00b0e68
commit 2b732bc11a
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package commands
import (
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/types"
pvm "github.com/tendermint/tendermint/types/priv_validator"
cmn "github.com/tendermint/tmlibs/common"
@ -28,6 +29,16 @@ func initFiles(cmd *cobra.Command, args []string) {
logger.Info("Generated private validator", "path", privValFile)
}
nodeKeyFile := config.NodeKeyFile()
if cmn.FileExists(nodeKeyFile) {
logger.Info("Found node key", "path", nodeKeyFile)
} else {
if _, err := p2p.LoadOrGenNodeKey(nodeKeyFile); err != nil {
panic(err)
}
logger.Info("Generated node key", "path", nodeKeyFile)
}
// genesis file
genFile := config.GenesisFile()
if cmn.FileExists(genFile) {