-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2649 from oasislabs/tjanez/cli-ux-improvements
Various CLI improvements
- Loading branch information
Showing
10 changed files
with
278 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Add `oasis-node registry node is-registered` subcommand. | ||
|
||
It checks whether the node is registered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Add `oasis-node identity tendermint show-{node,consensus}-address` subcommands. | ||
|
||
The `show-node-address` subcommmand returns node's public key converted to | ||
Tendermint's address format. | ||
It replaces the `oasis-node debug tendermint show-node-id` subcommand. | ||
|
||
The `show-consensus-address` subcommand returns node's consensus key converted | ||
to Tendermint's address format. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Make `oasis control is-synced` subcommand more verbose. | ||
|
||
Running `oasis-node control is-synced` will now print a message indicating | ||
whether a node has completed initial syncing or not to stdout in addition to | ||
returning an appropriate status code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Package tendermint implements the tendermint identity sub-commands. | ||
package tendermint | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"unicode" | ||
|
||
"github.com/spf13/cobra" | ||
flag "github.com/spf13/pflag" | ||
|
||
"github.com/oasislabs/oasis-core/go/common/crypto/signature" | ||
"github.com/oasislabs/oasis-core/go/common/identity" | ||
"github.com/oasislabs/oasis-core/go/common/logging" | ||
"github.com/oasislabs/oasis-core/go/consensus/tendermint/crypto" | ||
cmdCommon "github.com/oasislabs/oasis-core/go/oasis-node/cmd/common" | ||
cmdFlags "github.com/oasislabs/oasis-core/go/oasis-node/cmd/common/flags" | ||
tmCommon "github.com/tendermint/tendermint/libs/common" | ||
) | ||
|
||
var ( | ||
tmCmd = &cobra.Command{ | ||
Use: "tendermint", | ||
Short: "tendermint backend utilities", | ||
} | ||
|
||
tmShowNodeAddressCmd = &cobra.Command{ | ||
Use: "show-node-address", | ||
Short: "outputs node's tendermint address", | ||
Run: showNodeAddress, | ||
} | ||
|
||
tmShowConsensusAddressCmd = &cobra.Command{ | ||
Use: "show-consensus-address", | ||
Short: "outputs consensus' (validator's) tendermint address", | ||
Run: showConsensusAddress, | ||
} | ||
|
||
logger = logging.GetLogger("cmd/identity/tendermint") | ||
|
||
tmFlags = flag.NewFlagSet("", flag.ContinueOnError) | ||
) | ||
|
||
func printTmAddress(desc string, keyFile string) { | ||
if err := cmdCommon.Init(); err != nil { | ||
cmdCommon.EarlyLogAndExit(err) | ||
} | ||
|
||
var pubKey signature.PublicKey | ||
|
||
if err := pubKey.LoadPEM(filepath.Join(cmdCommon.DataDir(), keyFile), nil); err != nil { | ||
logger.Error("failed to open node's public key", | ||
"err", err, | ||
"key_file", keyFile, | ||
) | ||
os.Exit(1) | ||
} | ||
|
||
tmAddress := crypto.PublicKeyToTendermint(&pubKey).Address() | ||
if cmdFlags.Verbose() { | ||
descBytes := []byte(desc) | ||
descBytes[0] = byte(unicode.ToUpper(rune(descBytes[0]))) | ||
fmt.Printf("%s: %s (fingerprint: %X)\n", descBytes, tmAddress, tmCommon.Fingerprint(tmAddress)) | ||
} else { | ||
fmt.Println(tmAddress) | ||
} | ||
} | ||
|
||
func showNodeAddress(cmd *cobra.Command, args []string) { | ||
desc := strings.TrimPrefix(cmd.Short, "outputs ") | ||
printTmAddress(desc, identity.NodeKeyPubFilename) | ||
} | ||
|
||
func showConsensusAddress(cmd *cobra.Command, args []string) { | ||
desc := strings.TrimPrefix(cmd.Short, "outputs ") | ||
printTmAddress(desc, identity.ConsensusKeyPubFilename) | ||
} | ||
|
||
// Register registers the tendermint sub-command and all of it's children. | ||
func Register(parentCmd *cobra.Command) { | ||
tmCmd.AddCommand(tmShowNodeAddressCmd) | ||
tmCmd.AddCommand(tmShowConsensusAddressCmd) | ||
|
||
tmShowNodeAddressCmd.Flags().AddFlagSet(tmFlags) | ||
tmShowConsensusAddressCmd.Flags().AddFlagSet(tmFlags) | ||
|
||
parentCmd.AddCommand(tmCmd) | ||
} | ||
|
||
func init() { | ||
tmFlags.AddFlagSet(cmdFlags.VerboseFlags) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.