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,25 +17,31 @@ var Config = struct {
|
|||||||
PrivKey acm.PrivKey
|
PrivKey acm.PrivKey
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
var (
|
|
||||||
configFlag = cli.StringFlag{
|
|
||||||
Name: "config-file",
|
|
||||||
Value: ".debora/config.json",
|
|
||||||
Usage: "config file",
|
|
||||||
}
|
|
||||||
waitFlag = cli.BoolFlag{
|
|
||||||
Name: "wait",
|
|
||||||
Usage: "whether to wait for termination",
|
|
||||||
}
|
|
||||||
inputFlag = cli.StringFlag{
|
|
||||||
Name: "input",
|
|
||||||
Value: "",
|
|
||||||
Usage: "input to the program (e.g. stdin)",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Printf("New Debora Process (PID: %d)\n", os.Getpid())
|
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: rootDir + "/config.json",
|
||||||
|
Usage: "config file",
|
||||||
|
}
|
||||||
|
waitFlag = cli.BoolFlag{
|
||||||
|
Name: "wait",
|
||||||
|
Usage: "whether to wait for termination",
|
||||||
|
}
|
||||||
|
inputFlag = cli.StringFlag{
|
||||||
|
Name: "input",
|
||||||
|
Value: "",
|
||||||
|
Usage: "input to the program (e.g. stdin)",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "debora"
|
app.Name = "debora"
|
||||||
app.Usage = "summons commands to barak"
|
app.Usage = "summons commands to barak"
|
||||||
|
@ -20,7 +20,7 @@ func App() *confer.Config {
|
|||||||
appMtx.Lock()
|
appMtx.Lock()
|
||||||
defer appMtx.Unlock()
|
defer appMtx.Unlock()
|
||||||
if app == nil {
|
if app == nil {
|
||||||
Init(".tendermint")
|
Init("")
|
||||||
}
|
}
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
@ -104,7 +104,13 @@ func initDefaults(rootDir string) {
|
|||||||
|
|
||||||
func Init(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")
|
configFile := path.Join(rootDir, "config.toml")
|
||||||
genesisFile := path.Join(rootDir, "genesis.json")
|
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
|
// Get PrivValidator
|
||||||
var privValidator *sm.PrivValidator
|
var privValidator *sm.PrivValidator
|
||||||
if _, err := os.Stat(config.App().GetString("PrivValidatorFile")); err == nil {
|
privValidatorFile := config.App().GetString("PrivValidatorFile")
|
||||||
privValidator = sm.LoadPrivValidator(config.App().GetString("PrivValidatorFile"))
|
if _, err := os.Stat(privValidatorFile); err == nil {
|
||||||
log.Info("Loaded PrivValidator", "file", config.App().GetString("PrivValidatorFile"), "privValidator", privValidator)
|
privValidator = sm.LoadPrivValidator(privValidatorFile)
|
||||||
|
log.Info("Loaded PrivValidator",
|
||||||
|
"file", privValidatorFile, "privValidator", privValidator)
|
||||||
} else {
|
} 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)
|
eventSwitch := new(events.EventSwitch)
|
||||||
|
Reference in New Issue
Block a user