Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'ipfs dht findprovs --num-providers' to allow choosing number of providers to find #3966

Merged
merged 2 commits into from
Jun 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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