mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 13:51:21 +00:00
fixes from review
This commit is contained in:
@ -27,7 +27,7 @@ var ResetPrivValidatorCmd = &cobra.Command{
|
|||||||
// ResetAll removes the privValidator files.
|
// ResetAll removes the privValidator files.
|
||||||
// Exported so other CLI tools can use it
|
// Exported so other CLI tools can use it
|
||||||
func ResetAll(dbDir, privValFile string, logger log.Logger) {
|
func ResetAll(dbDir, privValFile string, logger log.Logger) {
|
||||||
resetPrivValidatorLocal(privValFile, logger)
|
resetPrivValidatorFS(privValFile, logger)
|
||||||
os.RemoveAll(dbDir)
|
os.RemoveAll(dbDir)
|
||||||
logger.Info("Removed all data", "dir", dbDir)
|
logger.Info("Removed all data", "dir", dbDir)
|
||||||
}
|
}
|
||||||
@ -41,10 +41,10 @@ func resetAll(cmd *cobra.Command, args []string) {
|
|||||||
// XXX: this is totally unsafe.
|
// XXX: this is totally unsafe.
|
||||||
// it's only suitable for testnets.
|
// it's only suitable for testnets.
|
||||||
func resetPrivValidator(cmd *cobra.Command, args []string) {
|
func resetPrivValidator(cmd *cobra.Command, args []string) {
|
||||||
resetPrivValidatorLocal(config.PrivValidatorFile(), logger)
|
resetPrivValidatorFS(config.PrivValidatorFile(), logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resetPrivValidatorLocal(privValFile string, logger log.Logger) {
|
func resetPrivValidatorFS(privValFile string, logger log.Logger) {
|
||||||
// Get PrivValidator
|
// Get PrivValidator
|
||||||
if _, err := os.Stat(privValFile); err == nil {
|
if _, err := os.Stat(privValFile); err == nil {
|
||||||
privValidator := types.LoadPrivValidatorFS(privValFile)
|
privValidator := types.LoadPrivValidatorFS(privValFile)
|
||||||
|
@ -5,10 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
cfg "github.com/tendermint/tendermint/config"
|
|
||||||
nm "github.com/tendermint/tendermint/node"
|
nm "github.com/tendermint/tendermint/node"
|
||||||
"github.com/tendermint/tendermint/proxy"
|
|
||||||
"github.com/tendermint/tendermint/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddNodeFlags exposes some common configuration options on the command-line
|
// AddNodeFlags exposes some common configuration options on the command-line
|
||||||
@ -39,27 +36,15 @@ func AddNodeFlags(cmd *cobra.Command) {
|
|||||||
cmd.Flags().Bool("consensus.create_empty_blocks", config.Consensus.CreateEmptyBlocks, "Set this to false to only produce blocks when there are txs or when the AppHash changes")
|
cmd.Flags().Bool("consensus.create_empty_blocks", config.Consensus.CreateEmptyBlocks, "Set this to false to only produce blocks when there are txs or when the AppHash changes")
|
||||||
}
|
}
|
||||||
|
|
||||||
// FuncSignerAndApp takes a config and returns a PrivValidator and ClientCreator.
|
|
||||||
// It allows other projects to make Tendermint binaries with custom signers and applications.
|
|
||||||
type FuncSignerAndApp func(*cfg.Config) (types.PrivValidator, proxy.ClientCreator)
|
|
||||||
|
|
||||||
// DefaultSignerAndApp is a default FuncSignerAndApp that returns a PrivValidatorFS
|
|
||||||
// and a DefaultClientCreator using the relevant fields from the config.
|
|
||||||
func DefaultSignerAndApp(config *cfg.Config) (types.PrivValidator, proxy.ClientCreator) {
|
|
||||||
privValidator := types.LoadOrGenPrivValidatorFS(config.PrivValidatorFile())
|
|
||||||
clientCreator := proxy.DefaultClientCreator(config.ProxyApp, config.ABCI, config.DBDir())
|
|
||||||
return privValidator, clientCreator
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRunNodeCmd returns the command that allows the CLI to start a
|
// NewRunNodeCmd returns the command that allows the CLI to start a
|
||||||
// node. It can be used with a custom PrivValidator and in-process ABCI application.
|
// node. It can be used with a custom PrivValidator and in-process ABCI application.
|
||||||
func NewRunNodeCmd(nodeFunc nm.NodeProvider) *cobra.Command {
|
func NewRunNodeCmd(nodeProvider nm.NodeProvider) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "node",
|
Use: "node",
|
||||||
Short: "Run the tendermint node",
|
Short: "Run the tendermint node",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
// Create & start node
|
// Create & start node
|
||||||
n, err := nodeFunc(config, logger)
|
n, err := nodeProvider(config, logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to create node: %v", err)
|
return fmt.Errorf("Failed to create node: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ type Node struct {
|
|||||||
func NewNode(config *cfg.Config,
|
func NewNode(config *cfg.Config,
|
||||||
privValidator types.PrivValidator,
|
privValidator types.PrivValidator,
|
||||||
clientCreator proxy.ClientCreator,
|
clientCreator proxy.ClientCreator,
|
||||||
genDocProvider GenesisDocProvider,
|
genesisDocProvider GenesisDocProvider,
|
||||||
dbProvider DBProvider,
|
dbProvider DBProvider,
|
||||||
logger log.Logger) (*Node, error) {
|
logger log.Logger) (*Node, error) {
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ func NewNode(config *cfg.Config,
|
|||||||
}
|
}
|
||||||
state := sm.LoadState(stateDB)
|
state := sm.LoadState(stateDB)
|
||||||
if state == nil {
|
if state == nil {
|
||||||
genDoc, err := genDocProvider()
|
genDoc, err := genesisDocProvider()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ func (privVal *PrivValidatorFS) signBytesHRS(height, round int, step int8, signB
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sign
|
// Sign
|
||||||
sig, err := privVal.Signer.Sign(signBytes)
|
sig, err := privVal.Sign(signBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sig, err
|
return sig, err
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ func (privVal *PrivValidatorFS) SignHeartbeat(chainID string, heartbeat *Heartbe
|
|||||||
privVal.mtx.Lock()
|
privVal.mtx.Lock()
|
||||||
defer privVal.mtx.Unlock()
|
defer privVal.mtx.Unlock()
|
||||||
var err error
|
var err error
|
||||||
heartbeat.Signature, err = privVal.Signer.Sign(SignBytes(chainID, heartbeat))
|
heartbeat.Signature, err = privVal.Sign(SignBytes(chainID, heartbeat))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user