mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-15 06:11:20 +00:00
Generate PrivValidator file when it doesn't exist already
This commit is contained in:
@ -17,10 +17,18 @@ var Config = struct {
|
||||
PrivKey acm.PrivKey
|
||||
}{}
|
||||
|
||||
var (
|
||||
func main() {
|
||||
fmt.Printf("New Debora Process (PID: %d)\n", os.Getpid())
|
||||
|
||||
rootDir := os.Getenv("DEBROOT")
|
||||
if rootDir == "" {
|
||||
rootDir = os.Getenv("HOME") + "/.debora"
|
||||
}
|
||||
|
||||
var (
|
||||
configFlag = cli.StringFlag{
|
||||
Name: "config-file",
|
||||
Value: ".debora/config.json",
|
||||
Value: rootDir + "/config.json",
|
||||
Usage: "config file",
|
||||
}
|
||||
waitFlag = cli.BoolFlag{
|
||||
@ -32,10 +40,8 @@ var (
|
||||
Value: "",
|
||||
Usage: "input to the program (e.g. stdin)",
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Printf("New Debora Process (PID: %d)\n", os.Getpid())
|
||||
app := cli.NewApp()
|
||||
app.Name = "debora"
|
||||
app.Usage = "summons commands to barak"
|
||||
|
@ -20,7 +20,7 @@ func App() *confer.Config {
|
||||
appMtx.Lock()
|
||||
defer appMtx.Unlock()
|
||||
if app == nil {
|
||||
Init(".tendermint")
|
||||
Init("")
|
||||
}
|
||||
return app
|
||||
}
|
||||
@ -104,7 +104,13 @@ func initDefaults(rootDir string) {
|
||||
|
||||
func Init(rootDir string) {
|
||||
|
||||
// Get RootDir
|
||||
// Get rootdir
|
||||
if rootDir == "" {
|
||||
rootDir = os.Getenv("TMROOT")
|
||||
}
|
||||
if rootDir == "" {
|
||||
rootDir = os.Getenv("HOME") + "/.tendermint"
|
||||
}
|
||||
configFile := path.Join(rootDir, "config.toml")
|
||||
genesisFile := path.Join(rootDir, "genesis.json")
|
||||
|
||||
|
34
node/id.go
Normal file
34
node/id.go
Normal file
@ -0,0 +1,34 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
acm "github.com/tendermint/tendermint/account"
|
||||
"time"
|
||||
)
|
||||
|
||||
type NodeID struct {
|
||||
Name string
|
||||
PubKey acm.PubKey
|
||||
}
|
||||
|
||||
type PrivNodeID struct {
|
||||
NodeID
|
||||
PrivKey acm.PrivKey
|
||||
}
|
||||
|
||||
type NodeGreeting struct {
|
||||
NodeID
|
||||
Version string
|
||||
Network string
|
||||
Message string
|
||||
Time time.Time
|
||||
}
|
||||
|
||||
type SignedNodeGreeting struct {
|
||||
NodeGreeting
|
||||
Signature acm.Signature
|
||||
}
|
||||
|
||||
func (pnid *PrivNodeID) SignGreeting() *SignedNodeGreeting {
|
||||
//greeting := NodeGreeting{}
|
||||
return nil
|
||||
}
|
13
node/node.go
13
node/node.go
@ -45,11 +45,16 @@ func NewNode() *Node {
|
||||
|
||||
// Get PrivValidator
|
||||
var privValidator *sm.PrivValidator
|
||||
if _, err := os.Stat(config.App().GetString("PrivValidatorFile")); err == nil {
|
||||
privValidator = sm.LoadPrivValidator(config.App().GetString("PrivValidatorFile"))
|
||||
log.Info("Loaded PrivValidator", "file", config.App().GetString("PrivValidatorFile"), "privValidator", privValidator)
|
||||
privValidatorFile := config.App().GetString("PrivValidatorFile")
|
||||
if _, err := os.Stat(privValidatorFile); err == nil {
|
||||
privValidator = sm.LoadPrivValidator(privValidatorFile)
|
||||
log.Info("Loaded PrivValidator",
|
||||
"file", privValidatorFile, "privValidator", privValidator)
|
||||
} else {
|
||||
log.Info("No PrivValidator found", "file", config.App().GetString("PrivValidatorFile"))
|
||||
privValidator = sm.GenPrivValidator()
|
||||
privValidator.SetFile(privValidatorFile)
|
||||
privValidator.Save()
|
||||
log.Info("Generated PrivValidator", "file", privValidatorFile)
|
||||
}
|
||||
|
||||
eventSwitch := new(events.EventSwitch)
|
||||
|
Reference in New Issue
Block a user