Merge pull request #67 from filecoin-project/feat/id-cmd
add an id command
This commit is contained in:
commit
978bd5c17e
@ -59,12 +59,12 @@ func reqContext(cctx *cli.Context) context.Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var Commands = []*cli.Command{
|
var Commands = []*cli.Command{
|
||||||
clientCmd,
|
|
||||||
chainCmd,
|
chainCmd,
|
||||||
|
clientCmd,
|
||||||
|
minerCmd,
|
||||||
|
mpoolCmd,
|
||||||
netCmd,
|
netCmd,
|
||||||
versionCmd,
|
versionCmd,
|
||||||
mpoolCmd,
|
|
||||||
minerCmd,
|
|
||||||
walletCmd,
|
walletCmd,
|
||||||
createMinerCmd,
|
createMinerCmd,
|
||||||
}
|
}
|
||||||
|
22
cli/net.go
22
cli/net.go
@ -19,6 +19,7 @@ var netCmd = &cli.Command{
|
|||||||
netPeers,
|
netPeers,
|
||||||
netConnect,
|
netConnect,
|
||||||
netListen,
|
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
|
// parseAddresses is a function that takes in a slice of string peer addresses
|
||||||
// (multiaddr + peerid) and returns a slice of properly constructed peers
|
// (multiaddr + peerid) and returns a slice of properly constructed peers
|
||||||
func parseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) {
|
func parseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user