From 2b732bc11aaa1ace7f9b61727ddcaa0ea11e0c5c Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Mon, 9 Apr 2018 15:41:26 +0200 Subject: [PATCH] generate node_key when running tendermint init --- cmd/tendermint/commands/init.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/tendermint/commands/init.go b/cmd/tendermint/commands/init.go index 22445264..2faff20f 100644 --- a/cmd/tendermint/commands/init.go +++ b/cmd/tendermint/commands/init.go @@ -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) {