mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
improve show_node_id
(#1433)
* fix show_node_id * make LoadNodeKey public * make LoadNodeKey public * remove if * remove if
This commit is contained in:
parent
6a48bd0c88
commit
384b3ea065
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/tendermint/tendermint/p2p"
|
"github.com/tendermint/tendermint/p2p"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ShowNodeIDCmd dumps node's ID to the standard output.
|
// ShowNodeIDCmd dumps node's ID to the standard output.
|
||||||
@ -16,10 +17,12 @@ var ShowNodeIDCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func showNodeID(cmd *cobra.Command, args []string) error {
|
func showNodeID(cmd *cobra.Command, args []string) error {
|
||||||
nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
|
|
||||||
|
nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(nodeKey.ID())
|
fmt.Println(nodeKey.ID())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func PubKeyToID(pubKey crypto.PubKey) ID {
|
|||||||
// If the file does not exist, it generates and saves a new NodeKey.
|
// If the file does not exist, it generates and saves a new NodeKey.
|
||||||
func LoadOrGenNodeKey(filePath string) (*NodeKey, error) {
|
func LoadOrGenNodeKey(filePath string) (*NodeKey, error) {
|
||||||
if cmn.FileExists(filePath) {
|
if cmn.FileExists(filePath) {
|
||||||
nodeKey, err := loadNodeKey(filePath)
|
nodeKey, err := LoadNodeKey(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ func LoadOrGenNodeKey(filePath string) (*NodeKey, error) {
|
|||||||
return genNodeKey(filePath)
|
return genNodeKey(filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadNodeKey(filePath string) (*NodeKey, error) {
|
func LoadNodeKey(filePath string) (*NodeKey, error) {
|
||||||
jsonBytes, err := ioutil.ReadFile(filePath)
|
jsonBytes, err := ioutil.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user