Skip to content

Commit

Permalink
Merge pull request #67 from filecoin-project/feat/id-cmd
Browse files Browse the repository at this point in the history
add an id command
  • Loading branch information
whyrusleeping committed Jul 22, 2019
2 parents 13e2179 + 4a34e20 commit 978bd5c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cli/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
22 changes: 22 additions & 0 deletions cli/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var netCmd = &cli.Command{
netPeers,
netConnect,
netListen,
netId,
},
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 978bd5c

Please sign in to comment.