Skip to content

Commit

Permalink
Merge pull request #3966 from torresashjian/fix/cmds/dht-findprovs-num
Browse files Browse the repository at this point in the history
Add 'ipfs dht findprovs --num-providers' to allow choosing number of providers to find
  • Loading branch information
whyrusleeping authored Jun 10, 2017
2 parents 10f9e77 + bfc9eec commit 77c5f56
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/commands/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ var findProvidersDhtCmd = &cmds.Command{
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.IntOption("num-providers", "n", "The number of providers to find.").Default(20),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand All @@ -159,7 +160,15 @@ var findProvidersDhtCmd = &cmds.Command{
return
}

numProviders := 20
numProviders, _, err := res.Request().Option("num-providers").Int()
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
if numProviders < 1 {
res.SetError(fmt.Errorf("Number of providers must be greater than 0"), cmds.ErrNormal)
return
}

outChan := make(chan interface{})
res.SetOutput((<-chan interface{})(outChan))
Expand Down

0 comments on commit 77c5f56

Please sign in to comment.