Merge pull request #67 from filecoin-project/feat/id-cmd

add an id command
This commit is contained in:
Whyrusleeping 2019-07-22 13:28:21 -07:00 committed by GitHub
commit 978bd5c17e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 3 deletions

View File

@ -59,12 +59,12 @@ func reqContext(cctx *cli.Context) context.Context {
}
var Commands = []*cli.Command{
clientCmd,
chainCmd,
clientCmd,
minerCmd,
mpoolCmd,
netCmd,
versionCmd,
mpoolCmd,
minerCmd,
walletCmd,
createMinerCmd,
}

View File

@ -19,6 +19,7 @@ var netCmd = &cli.Command{
netPeers,
netConnect,
netListen,
netId,
},
}
@ -95,6 +96,27 @@ var netConnect = &cli.Command{
},
}
var netId = &cli.Command{
Name: "id",
Usage: "Get node identity",
Action: func(cctx *cli.Context) error {
api, err := getAPI(cctx)
if err != nil {
return err
}
ctx := reqContext(cctx)
pid, err := api.ID(ctx)
if err != nil {
return err
}
fmt.Println(pid)
return nil
},
}
// parseAddresses is a function that takes in a slice of string peer addresses
// (multiaddr + peerid) and returns a slice of properly constructed peers
func parseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) {