Browse Source

cmd: show useful error when tm not initialised (#4512)

Closes #4303

Before:

```
TMHOME="/Users/daniel/go/src/github.com/tendermint/thome" tendermint node --proxy_app=unix:///Users/daniel/go/src/github.com/kvstore/example.sock

ERROR: 1 error(s) decoding:

* error decoding 'consensus.create_empty_blocks_interval': time: invalid duration
```

After:

```
$ TMHOME=/tmp ./build/tendermint node --proxy_app=kvstore
ERROR: failed to create node: Couldn't read GenesisDoc file: open /tmp/config/genesis.json: no such file or directory
```
pull/4516/head
Anton Kaliaev 5 years ago
committed by GitHub
parent
commit
3b2e1f22e4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 11 deletions
  1. +12
    -11
      cmd/tendermint/commands/run_node.go

+ 12
- 11
cmd/tendermint/commands/run_node.go View File

@ -78,7 +78,7 @@ func AddNodeFlags(cmd *cobra.Command) {
"Set this to false to only produce blocks when there are txs or when the AppHash changes")
cmd.Flags().String(
"consensus.create_empty_blocks_interval",
string(config.Consensus.CreateEmptyBlocksInterval),
config.Consensus.CreateEmptyBlocksInterval.String(),
"The possible interval between empty blocks")
// db flags
@ -99,11 +99,21 @@ func NewRunNodeCmd(nodeProvider nm.Provider) *cobra.Command {
Use: "node",
Short: "Run the tendermint node",
RunE: func(cmd *cobra.Command, args []string) error {
if err := checkGenesisHash(config); err != nil {
return err
}
n, err := nodeProvider(config, logger)
if err != nil {
return fmt.Errorf("failed to create node: %v", err)
return fmt.Errorf("failed to create node: %w", err)
}
if err := n.Start(); err != nil {
return fmt.Errorf("failed to start node: %w", err)
}
logger.Info("Started node", "nodeInfo", n.Switch().NodeInfo())
// Stop upon receiving SIGTERM or CTRL-C.
tmos.TrapSignal(logger, func() {
if n.IsRunning() {
@ -111,15 +121,6 @@ func NewRunNodeCmd(nodeProvider nm.Provider) *cobra.Command {
}
})
if err := checkGenesisHash(config); err != nil {
return err
}
if err := n.Start(); err != nil {
return fmt.Errorf("failed to start node: %v", err)
}
logger.Info("Started node", "nodeInfo", n.Switch().NodeInfo())
// Run forever.
select {}
},


Loading…
Cancel
Save