Browse Source

fixes from review

pull/637/head
Ethan Buchman 7 years ago
parent
commit
756818f940
5 changed files with 10 additions and 25 deletions
  1. +3
    -3
      cmd/tendermint/commands/reset_priv_validator.go
  2. +2
    -17
      cmd/tendermint/commands/run_node.go
  3. +1
    -1
      cmd/tendermint/main.go
  4. +2
    -2
      node/node.go
  5. +2
    -2
      types/priv_validator.go

+ 3
- 3
cmd/tendermint/commands/reset_priv_validator.go View File

@ -27,7 +27,7 @@ var ResetPrivValidatorCmd = &cobra.Command{
// ResetAll removes the privValidator files.
// Exported so other CLI tools can use it
func ResetAll(dbDir, privValFile string, logger log.Logger) {
resetPrivValidatorLocal(privValFile, logger)
resetPrivValidatorFS(privValFile, logger)
os.RemoveAll(dbDir)
logger.Info("Removed all data", "dir", dbDir)
}
@ -41,10 +41,10 @@ func resetAll(cmd *cobra.Command, args []string) {
// XXX: this is totally unsafe.
// it's only suitable for testnets.
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
if _, err := os.Stat(privValFile); err == nil {
privValidator := types.LoadPrivValidatorFS(privValFile)


+ 2
- 17
cmd/tendermint/commands/run_node.go View File

@ -5,10 +5,7 @@ import (
"github.com/spf13/cobra"
cfg "github.com/tendermint/tendermint/config"
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
@ -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")
}
// 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
// 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{
Use: "node",
Short: "Run the tendermint node",
RunE: func(cmd *cobra.Command, args []string) error {
// Create & start node
n, err := nodeFunc(config, logger)
n, err := nodeProvider(config, logger)
if err != nil {
return fmt.Errorf("Failed to create node: %v", err)
}


+ 1
- 1
cmd/tendermint/main.go View File

@ -28,7 +28,7 @@ func main() {
// * Use an external signer for their validators
// * Supply an in-proc abci app
// * Supply a genesis doc file from another source
// * Provide their own DB implementation
// * Provide their own DB implementation
// can copy this file and use something other than the
// DefaultNewNode function
nodeFunc := nm.DefaultNewNode


+ 2
- 2
node/node.go View File

@ -113,7 +113,7 @@ type Node struct {
func NewNode(config *cfg.Config,
privValidator types.PrivValidator,
clientCreator proxy.ClientCreator,
genDocProvider GenesisDocProvider,
genesisDocProvider GenesisDocProvider,
dbProvider DBProvider,
logger log.Logger) (*Node, error) {
@ -134,7 +134,7 @@ func NewNode(config *cfg.Config,
}
state := sm.LoadState(stateDB)
if state == nil {
genDoc, err := genDocProvider()
genDoc, err := genesisDocProvider()
if err != nil {
return nil, err
}


+ 2
- 2
types/priv_validator.go View File

@ -258,7 +258,7 @@ func (privVal *PrivValidatorFS) signBytesHRS(height, round int, step int8, signB
}
// Sign
sig, err := privVal.Signer.Sign(signBytes)
sig, err := privVal.Sign(signBytes)
if err != nil {
return sig, err
}
@ -280,7 +280,7 @@ func (privVal *PrivValidatorFS) SignHeartbeat(chainID string, heartbeat *Heartbe
privVal.mtx.Lock()
defer privVal.mtx.Unlock()
var err error
heartbeat.Signature, err = privVal.Signer.Sign(SignBytes(chainID, heartbeat))
heartbeat.Signature, err = privVal.Sign(SignBytes(chainID, heartbeat))
return err
}


Loading…
Cancel
Save