1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 09:52:20 +08:00

cmds/id: use req context -- dont timeout unnecessarily

commands should last as long as the user keeps the cmd going
This commit is contained in:
Juan Batiz-Benet
2015-03-07 09:23:15 -08:00
parent aa55eebe7e
commit dfe2b16763

View File

@ -7,10 +7,8 @@ import (
"errors" "errors"
"io" "io"
"strings" "strings"
"time"
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
cmds "github.com/jbenet/go-ipfs/commands" cmds "github.com/jbenet/go-ipfs/commands"
core "github.com/jbenet/go-ipfs/core" core "github.com/jbenet/go-ipfs/core"
@ -81,14 +79,13 @@ ipfs id supports the format option for output with the following keys:
return return
} }
ctx, _ := context.WithTimeout(context.TODO(), time.Second*5)
// TODO handle offline mode with polymorphism instead of conditionals // TODO handle offline mode with polymorphism instead of conditionals
if !node.OnlineMode() { if !node.OnlineMode() {
res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient) res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient)
return return
} }
p, err := node.Routing.FindPeer(ctx, id) p, err := node.Routing.FindPeer(req.Context().Context, id)
if err == kb.ErrLookupFailure { if err == kb.ErrLookupFailure {
res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient) res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient)
return return