mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-25 12:11:22 +00:00
do not overwrite existing files when doing tendermint init
(Fixes #410)
This commit is contained in:
parent
3ebd69db1b
commit
a99885cd43
@ -1,24 +1,35 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/tendermint/go-common"
|
"os"
|
||||||
|
|
||||||
|
cmn "github.com/tendermint/go-common"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init_files() {
|
func init_files() {
|
||||||
privValidator := types.GenPrivValidator()
|
privValFile := config.GetString("priv_validator_file")
|
||||||
privValidator.SetFile(config.GetString("priv_validator_file"))
|
if _, err := os.Stat(privValFile); os.IsNotExist(err) {
|
||||||
privValidator.Save()
|
privValidator := types.GenPrivValidator()
|
||||||
|
privValidator.SetFile(privValFile)
|
||||||
|
privValidator.Save()
|
||||||
|
|
||||||
genDoc := types.GenesisDoc{
|
genFile := config.GetString("genesis_file")
|
||||||
ChainID: Fmt("test-chain-%v", RandStr(6)),
|
|
||||||
|
if _, err := os.Stat(genFile); os.IsNotExist(err) {
|
||||||
|
genDoc := types.GenesisDoc{
|
||||||
|
ChainID: cmn.Fmt("test-chain-%v", cmn.RandStr(6)),
|
||||||
|
}
|
||||||
|
genDoc.Validators = []types.GenesisValidator{types.GenesisValidator{
|
||||||
|
PubKey: privValidator.PubKey,
|
||||||
|
Amount: 10,
|
||||||
|
}}
|
||||||
|
|
||||||
|
genDoc.SaveAs(genFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Notice("Initialized tendermint", "genesis", config.GetString("genesis_file"), "priv_validator", config.GetString("priv_validator_file"))
|
||||||
|
} else {
|
||||||
|
log.Notice("Already initialized", "priv_validator", config.GetString("priv_validator_file"))
|
||||||
}
|
}
|
||||||
genDoc.Validators = []types.GenesisValidator{types.GenesisValidator{
|
|
||||||
PubKey: privValidator.PubKey,
|
|
||||||
Amount: 10,
|
|
||||||
}}
|
|
||||||
|
|
||||||
genDoc.SaveAs(config.GetString("genesis_file"))
|
|
||||||
|
|
||||||
log.Notice("Initialized tendermint", "genesis", config.GetString("genesis_file"), "priv_validator", config.GetString("priv_validator_file"))
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user