remove context from context
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Jul 20, 2015 at 18:45 UTC
bb3a75aa08fa7ce17848484ba9070e6698ce06e8
35 files changed
+186
-176
cmd/ipfs/daemon.go
+15
-15
@@ -110,11 +110,11 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
110
// let the user know we're going.
111
fmt.Printf("Initializing daemon...\n")
112
113
- ctx := req.Context()
113
+ ctx := req.InvocContext()
114
115
go func() {
116
select {
117
- case <-ctx.Context.Done():
117
+ case <-req.Context().Done():
118
fmt.Println("Received interrupt signal, shutting down...")
119
}
120
}()
@@ -141,8 +141,8 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
141
// configured. Consider moving this into a config helper method
142
// `IsInitialized` where the quality of the signal can be improved over
143
// time, and many call-sites can benefit.
144
- if !util.FileExists(req.Context().ConfigRoot) {
145
- err := initWithDefaults(os.Stdout, req.Context().ConfigRoot)
144
+ if !util.FileExists(req.InvocContext().ConfigRoot) {
145
+ err := initWithDefaults(os.Stdout, req.InvocContext().ConfigRoot)
146
if err != nil {
147
res.SetError(err, cmds.ErrNormal)
148
return
@@ -152,7 +152,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
152
153
// acquire the repo lock _before_ constructing a node. we need to make
154
// sure we are permitted to access the resources (datastore, etc.)
155
- repo, err := fsrepo.Open(req.Context().ConfigRoot)
155
+ repo, err := fsrepo.Open(req.InvocContext().ConfigRoot)
156
if err != nil {
157
res.SetError(err, cmds.ErrNormal)
158
return
@@ -190,7 +190,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
190
nb.SetRouting(corerouting.SupernodeClient(infos...))
191
}
192
193
- node, err := nb.Build(ctx.Context)
193
+ node, err := nb.Build(req.Context())
194
if err != nil {
195
log.Error("error from node construction: ", err)
196
res.SetError(err, cmds.ErrNormal)
@@ -205,13 +205,13 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
205
node.Close()
206
207
select {
208
- case <-ctx.Context.Done():
208
+ case <-req.Context().Done():
209
log.Info("Gracefully shut down daemon")
210
default:
211
}
212
}()
213
214
- req.Context().ConstructNode = func() (*core.IpfsNode, error) {
214
+ req.InvocContext().ConstructNode = func() (*core.IpfsNode, error) {
215
return node, nil
216
}
217
@@ -258,7 +258,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
258
259
// serveHTTPApi collects options, creates listener, prints status message and starts serving requests
260
func serveHTTPApi(req cmds.Request) (error, <-chan error) {
261
- cfg, err := req.Context().GetConfig()
261
+ cfg, err := req.InvocContext().GetConfig()
262
if err != nil {
263
return fmt.Errorf("serveHTTPApi: GetConfig() failed: %s", err), nil
264
}
@@ -299,7 +299,7 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) {
299
},
300
})
301
var opts = []corehttp.ServeOption{
302
- corehttp.CommandsOption(*req.Context()),
302
+ corehttp.CommandsOption(*req.InvocContext()),
303
corehttp.WebUIOption,
304
apiGw.ServeOption(),
305
corehttp.VersionOption(),
@@ -313,7 +313,7 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) {
313
opts = append(opts, corehttp.RedirectOption("", cfg.Gateway.RootRedirect))
314
}
315
316
- node, err := req.Context().ConstructNode()
316
+ node, err := req.InvocContext().ConstructNode()
317
if err != nil {
318
return fmt.Errorf("serveHTTPGateway: ConstructNode() failed: %s", err), nil
319
}
@@ -341,7 +341,7 @@ func printSwarmAddrs(node *core.IpfsNode) {
341
342
// serveHTTPGateway collects options, creates listener, prints status message and starts serving requests
343
func serveHTTPGateway(req cmds.Request) (error, <-chan error) {
344
- cfg, err := req.Context().GetConfig()
344
+ cfg, err := req.InvocContext().GetConfig()
345
if err != nil {
346
return fmt.Errorf("serveHTTPGateway: GetConfig() failed: %s", err), nil
347
}
@@ -382,7 +382,7 @@ func serveHTTPGateway(req cmds.Request) (error, <-chan error) {
382
opts = append(opts, corehttp.RedirectOption("", cfg.Gateway.RootRedirect))
383
}
384
385
- node, err := req.Context().ConstructNode()
385
+ node, err := req.InvocContext().ConstructNode()
386
if err != nil {
387
return fmt.Errorf("serveHTTPGateway: ConstructNode() failed: %s", err), nil
388
}
@@ -397,7 +397,7 @@ func serveHTTPGateway(req cmds.Request) (error, <-chan error) {
397
398
//collects options and opens the fuse mountpoint
399
func mountFuse(req cmds.Request) error {
400
- cfg, err := req.Context().GetConfig()
400
+ cfg, err := req.InvocContext().GetConfig()
401
if err != nil {
402
return fmt.Errorf("mountFuse: GetConfig() failed: %s", err)
403
}
@@ -418,7 +418,7 @@ func mountFuse(req cmds.Request) error {
418
nsdir = cfg.Mounts.IPNS
419
}
420
421
- node, err := req.Context().ConstructNode()
421
+ node, err := req.InvocContext().ConstructNode()
422
if err != nil {
423
return fmt.Errorf("mountFuse: ConstructNode() failed: %s", err)
424
}
cmd/ipfs/init.go
+3
-3
@@ -34,7 +34,7 @@ var initCmd = &cmds.Command{
34
// TODO cmds.StringOption("event-logs", "l", "Location for machine-readable event logs"),
35
},
36
PreRun: func(req cmds.Request) error {
37
- daemonLocked, err := fsrepo.LockedByOtherProcess(req.Context().ConfigRoot)
37
+ daemonLocked, err := fsrepo.LockedByOtherProcess(req.InvocContext().ConfigRoot)
38
if err != nil {
39
return err
40
}
@@ -48,7 +48,7 @@ var initCmd = &cmds.Command{
48
return nil
49
},
50
Run: func(req cmds.Request, res cmds.Response) {
51
- if req.Context().Online {
51
+ if req.InvocContext().Online {
52
res.SetError(errors.New("init must be run offline only!"), cmds.ErrNormal)
53
return
54
}
@@ -69,7 +69,7 @@ var initCmd = &cmds.Command{
69
nBitsForKeypair = nBitsForKeypairDefault
70
}
71
72
- if err := doInit(os.Stdout, req.Context().ConfigRoot, force, nBitsForKeypair); err != nil {
72
+ if err := doInit(os.Stdout, req.InvocContext().ConfigRoot, force, nBitsForKeypair); err != nil {
73
res.SetError(err, cmds.ErrNormal)
74
return
75
}
cmd/ipfs/main.go
+11
-10
@@ -192,12 +192,12 @@ func (i *cmdInvocation) constructNodeFunc(ctx context.Context) func() (*core.Ipf
192
return nil, errors.New("constructing node without a request")
193
}
194
195
- cmdctx := i.req.Context()
195
+ cmdctx := i.req.InvocContext()
196
if cmdctx == nil {
197
return nil, errors.New("constructing node without a request context")
198
}
199
200
- r, err := fsrepo.Open(i.req.Context().ConfigRoot)
200
+ r, err := fsrepo.Open(i.req.InvocContext().ConfigRoot)
201
if err != nil { // repo is owned by the node
202
return nil, err
203
}
@@ -238,7 +238,7 @@ func (i *cmdInvocation) Parse(ctx context.Context, args []string) error {
238
log.Debugf("config path is %s", repoPath)
239
240
// this sets up the function that will initialize the config lazily.
241
- cmdctx := i.req.Context()
241
+ cmdctx := i.req.InvocContext()
242
cmdctx.ConfigRoot = repoPath
243
cmdctx.LoadConfig = loadConfig
244
// this sets up the function that will initialize the node
@@ -279,10 +279,13 @@ func callPreCommandHooks(ctx context.Context, details cmdDetails, req cmds.Reque
279
}
280
281
func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd *cmds.Command) (cmds.Response, error) {
282
- log.Info(config.EnvDir, " ", req.Context().ConfigRoot)
282
+ log.Info(config.EnvDir, " ", req.InvocContext().ConfigRoot)
283
var res cmds.Response
284
285
- req.Context().Context = ctx
285
+ err := req.SetRootContext(ctx)
286
+ if err != nil {
287
+ return nil, err
288
+ }
289
290
details, err := commandDetails(req.Path(), root)
291
if err != nil {
@@ -309,7 +312,7 @@ func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd
312
313
if useDaemon {
314
312
- cfg, err := req.Context().GetConfig()
315
+ cfg, err := req.InvocContext().GetConfig()
316
if err != nil {
317
return nil, err
318
}
@@ -335,13 +338,11 @@ func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd
338
} else {
339
log.Debug("Executing command locally")
340
338
- ctx, err := cmds.GetContext(ctx, req)
341
+ err := req.SetRootContext(ctx)
342
if err != nil {
343
return nil, err
344
}
345
343
- req.Context().Context = ctx
344
-
346
// Okay!!!!! NOW we can call the command.
347
res = root.Call(req)
348
@@ -399,7 +400,7 @@ func commandShouldRunOnDaemon(details cmdDetails, req cmds.Request, root *cmds.C
400
401
// at this point need to know whether daemon is running. we defer
402
// to this point so that some commands dont open files unnecessarily.
402
- daemonLocked, err := fsrepo.LockedByOtherProcess(req.Context().ConfigRoot)
403
+ daemonLocked, err := fsrepo.LockedByOtherProcess(req.InvocContext().ConfigRoot)
404
if err != nil {
405
return false, err
406
}
cmd/ipfswatch/main.go
-2
@@ -185,8 +185,6 @@ func IsHidden(path string) bool {
185
186
func cmdCtx(node *core.IpfsNode, repoPath string) commands.Context {
187
return commands.Context{
188
- // TODO deprecate this shit
189
- Context: context.Background(),
188
Online: true,
189
ConfigRoot: repoPath,
190
LoadConfig: func(path string) (*config.Config, error) {
commands/http/client.go
+2
-2
@@ -84,7 +84,7 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) {
84
85
ec := make(chan error, 1)
86
rc := make(chan cmds.Response, 1)
87
- dc := req.Context().Context.Done()
87
+ dc := req.Context().Done()
88
89
go func() {
90
httpRes, err := http.DefaultClient.Do(httpReq)
@@ -181,7 +181,7 @@ func getResponse(httpRes *http.Response, req cmds.Request) (cmds.Response, error
181
dec := json.NewDecoder(httpRes.Body)
182
outputType := reflect.TypeOf(req.Command().Type)
183
184
- ctx := req.Context().Context
184
+ ctx := req.Context()
185
186
for {
187
var v interface{}
commands/http/handler.go
+3
-7
@@ -106,18 +106,14 @@ func (i internalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
106
return
107
}
108
109
- ctx, err := cmds.GetContext(node.Context(), req)
109
+ //ps: take note of the name clash - commands.Context != context.Context
110
+ req.SetInvocContext(i.ctx)
111
+ err = req.SetRootContext(node.Context())
112
if err != nil {
111
- err = fmt.Errorf("error parsing timeout option: %s", err)
113
http.Error(w, err.Error(), http.StatusInternalServerError)
114
return
115
}
116
116
- //ps: take note of the name clash - commands.Context != context.Context
117
- cmdctx := i.ctx
118
- cmdctx.Context = ctx
119
- req.SetContext(cmdctx)
120
-
117
// call the command
118
res := i.root.Call(req)
119
commands/request.go
+55
-38
@@ -19,10 +19,6 @@ import (
19
type OptMap map[string]interface{}
20
21
type Context struct {
22
- // this Context is temporary. Will be replaced soon, as we get
23
- // rid of this variable entirely.
24
- Context context.Context
25
-
22
Online bool
23
ConfigRoot string
24
@@ -76,8 +72,10 @@ type Request interface {
72
SetArguments([]string)
73
Files() files.File
74
SetFiles(files.File)
79
- Context() *Context
80
- SetContext(Context)
75
+ Context() context.Context
76
+ SetRootContext(context.Context) error
77
+ InvocContext() *Context
78
+ SetInvocContext(Context)
79
Command() *Command
80
Values() map[string]interface{}
81
Stdin() io.Reader
@@ -92,6 +90,7 @@ type request struct {
90
files files.File
91
cmd *Command
92
ctx Context
93
+ rctx context.Context
94
optionDefs map[string]Option
95
values map[string]interface{}
96
stdin io.Reader
@@ -131,6 +130,16 @@ func (r *request) Options() OptMap {
130
return output
131
}
132
133
+func (r *request) SetRootContext(ctx context.Context) error {
134
+ ctx, err := getContext(ctx, r)
135
+ if err != nil {
136
+ return err
137
+ }
138
+
139
+ r.rctx = ctx
140
+ return nil
141
+}
142
+
143
// SetOption sets the value of the option for given name.
144
func (r *request) SetOption(name string, val interface{}) {
145
// find the option with the specified name
@@ -174,11 +183,37 @@ func (r *request) SetFiles(f files.File) {
183
r.files = f
184
}
185
177
-func (r *request) Context() *Context {
186
+func (r *request) Context() context.Context {
187
+ return r.rctx
188
+}
189
+
190
+func getContext(base context.Context, req Request) (context.Context, error) {
191
+ tout, found, err := req.Option("timeout").String()
192
+ if err != nil {
193
+ return nil, fmt.Errorf("error parsing timeout option: %s", err)
194
+ }
195
+
196
+ var ctx context.Context
197
+ if found {
198
+ duration, err := time.ParseDuration(tout)
199
+ if err != nil {
200
+ return nil, fmt.Errorf("error parsing timeout option: %s", err)
201
+ }
202
+
203
+ tctx, _ := context.WithTimeout(base, duration)
204
+ ctx = tctx
205
+ } else {
206
+ cctx, _ := context.WithCancel(base)
207
+ ctx = cctx
208
+ }
209
+ return ctx, nil
210
+}
211
+
212
+func (r *request) InvocContext() *Context {
213
return &r.ctx
214
}
215
181
-func (r *request) SetContext(ctx Context) {
216
+func (r *request) SetInvocContext(ctx Context) {
217
r.ctx = ctx
218
}
219
@@ -275,22 +310,26 @@ func NewEmptyRequest() (Request, error) {
310
// NewRequest returns a request initialized with given arguments
311
// An non-nil error will be returned if the provided option values are invalid
312
func NewRequest(path []string, opts OptMap, args []string, file files.File, cmd *Command, optDefs map[string]Option) (Request, error) {
278
- if path == nil {
279
- path = make([]string, 0)
280
- }
313
if opts == nil {
314
opts = make(OptMap)
315
}
284
- if args == nil {
285
- args = make([]string, 0)
286
- }
316
if optDefs == nil {
317
optDefs = make(map[string]Option)
318
}
319
291
- ctx := Context{Context: context.TODO()}
320
+ ctx := Context{}
321
values := make(map[string]interface{})
293
- req := &request{path, opts, args, file, cmd, ctx, optDefs, values, os.Stdin}
322
+ req := &request{
323
+ path: path,
324
+ options: opts,
325
+ arguments: args,
326
+ files: file,
327
+ cmd: cmd,
328
+ ctx: ctx,
329
+ optionDefs: optDefs,
330
+ values: values,
331
+ stdin: os.Stdin,
332
+ }
333
err := req.ConvertOptions()
334
if err != nil {
335
return nil, err
@@ -298,25 +337,3 @@ func NewRequest(path []string, opts OptMap, args []string, file files.File, cmd
337
338
return req, nil
339
}
301
-
302
-func GetContext(base context.Context, req Request) (context.Context, error) {
303
- tout, found, err := req.Option("timeout").String()
304
- if err != nil {
305
- return nil, fmt.Errorf("error parsing timeout option: %s", err)
306
- }
307
-
308
- var ctx context.Context
309
- if found {
310
- duration, err := time.ParseDuration(tout)
311
- if err != nil {
312
- return nil, fmt.Errorf("error parsing timeout option: %s", err)
313
- }
314
-
315
- tctx, _ := context.WithTimeout(base, duration)
316
- ctx = tctx
317
- } else {
318
- cctx, _ := context.WithCancel(base)
319
- ctx = cctx
320
- }
321
- return ctx, nil
322
-}
core/commands/add.go
+1
-1
@@ -88,7 +88,7 @@ remains to be implemented.
88
return nil
89
},
90
Run: func(req cmds.Request, res cmds.Response) {
91
- n, err := req.Context().GetNode()
91
+ n, err := req.InvocContext().GetNode()
92
if err != nil {
93
res.SetError(err, cmds.ErrNormal)
94
return
core/commands/bitswap.go
+2
-2
@@ -33,7 +33,7 @@ Print out all blocks currently on the bitswap wantlist for the local peer`,
33
},
34
Type: KeyList{},
35
Run: func(req cmds.Request, res cmds.Response) {
36
- nd, err := req.Context().GetNode()
36
+ nd, err := req.InvocContext().GetNode()
37
if err != nil {
38
res.SetError(err, cmds.ErrNormal)
39
return
@@ -78,7 +78,7 @@ var bitswapStatCmd = &cmds.Command{
78
},
79
Type: bitswap.Stat{},
80
Run: func(req cmds.Request, res cmds.Response) {
81
- nd, err := req.Context().GetNode()
81
+ nd, err := req.InvocContext().GetNode()
82
if err != nil {
83
res.SetError(err, cmds.ErrNormal)
84
return
core/commands/block.go
+3
-3
@@ -114,7 +114,7 @@ It reads from stdin, and <key> is a base58 encoded multihash.
114
cmds.FileArg("data", true, false, "The data to be stored as an IPFS block").EnableStdin(),
115
},
116
Run: func(req cmds.Request, res cmds.Response) {
117
- n, err := req.Context().GetNode()
117
+ n, err := req.InvocContext().GetNode()
118
if err != nil {
119
res.SetError(err, cmds.ErrNormal)
120
return
@@ -162,7 +162,7 @@ It reads from stdin, and <key> is a base58 encoded multihash.
162
}
163
164
func getBlockForKey(req cmds.Request, skey string) (*blocks.Block, error) {
165
- n, err := req.Context().GetNode()
165
+ n, err := req.InvocContext().GetNode()
166
if err != nil {
167
return nil, err
168
}
@@ -177,7 +177,7 @@ func getBlockForKey(req cmds.Request, skey string) (*blocks.Block, error) {
177
}
178
179
k := key.Key(h)
180
- b, err := n.Blocks.GetBlock(req.Context().Context, k)
180
+ b, err := n.Blocks.GetBlock(req.Context(), k)
181
if err != nil {
182
return nil, err
183
}
core/commands/bootstrap.go
+3
-3
@@ -66,7 +66,7 @@ in the bootstrap list).
66
return
67
}
68
69
- r, err := fsrepo.Open(req.Context().ConfigRoot)
69
+ r, err := fsrepo.Open(req.InvocContext().ConfigRoot)
70
if err != nil {
71
res.SetError(err, cmds.ErrNormal)
72
return
@@ -142,7 +142,7 @@ var bootstrapRemoveCmd = &cmds.Command{
142
return
143
}
144
145
- r, err := fsrepo.Open(req.Context().ConfigRoot)
145
+ r, err := fsrepo.Open(req.InvocContext().ConfigRoot)
146
if err != nil {
147
res.SetError(err, cmds.ErrNormal)
148
return
@@ -191,7 +191,7 @@ var bootstrapListCmd = &cmds.Command{
191
},
192
193
Run: func(req cmds.Request, res cmds.Response) {
194
- r, err := fsrepo.Open(req.Context().ConfigRoot)
194
+ r, err := fsrepo.Open(req.InvocContext().ConfigRoot)
195
if err != nil {
196
res.SetError(err, cmds.ErrNormal)
197
return
core/commands/cat.go
+2
-2
@@ -27,13 +27,13 @@ it contains.
27
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted").EnableStdin(),
28
},
29
Run: func(req cmds.Request, res cmds.Response) {
30
- node, err := req.Context().GetNode()
30
+ node, err := req.InvocContext().GetNode()
31
if err != nil {
32
res.SetError(err, cmds.ErrNormal)
33
return
34
}
35
36
- readers, length, err := cat(req.Context().Context, node, req.Arguments())
36
+ readers, length, err := cat(req.Context(), node, req.Arguments())
37
if err != nil {
38
res.SetError(err, cmds.ErrNormal)
39
return
core/commands/config.go
+4
-4
@@ -65,7 +65,7 @@ Set the value of the 'datastore.path' key:
65
args := req.Arguments()
66
key := args[0]
67
68
- r, err := fsrepo.Open(req.Context().ConfigRoot)
68
+ r, err := fsrepo.Open(req.InvocContext().ConfigRoot)
69
if err != nil {
70
res.SetError(err, cmds.ErrNormal)
71
return
@@ -141,7 +141,7 @@ included in the output of this command.
141
},
142
143
Run: func(req cmds.Request, res cmds.Response) {
144
- filename, err := config.Filename(req.Context().ConfigRoot)
144
+ filename, err := config.Filename(req.InvocContext().ConfigRoot)
145
if err != nil {
146
res.SetError(err, cmds.ErrNormal)
147
return
@@ -166,7 +166,7 @@ variable set to your preferred text editor.
166
},
167
168
Run: func(req cmds.Request, res cmds.Response) {
169
- filename, err := config.Filename(req.Context().ConfigRoot)
169
+ filename, err := config.Filename(req.InvocContext().ConfigRoot)
170
if err != nil {
171
res.SetError(err, cmds.ErrNormal)
172
return
@@ -192,7 +192,7 @@ can't be undone.
192
cmds.FileArg("file", true, false, "The file to use as the new config"),
193
},
194
Run: func(req cmds.Request, res cmds.Response) {
195
- r, err := fsrepo.Open(req.Context().ConfigRoot)
195
+ r, err := fsrepo.Open(req.InvocContext().ConfigRoot)
196
if err != nil {
197
res.SetError(err, cmds.ErrNormal)
198
return
core/commands/dht.go
+10
-10
@@ -45,7 +45,7 @@ var queryDhtCmd = &cmds.Command{
45
cmds.BoolOption("verbose", "v", "Write extra information"),
46
},
47
Run: func(req cmds.Request, res cmds.Response) {
48
- n, err := req.Context().GetNode()
48
+ n, err := req.InvocContext().GetNode()
49
if err != nil {
50
res.SetError(err, cmds.ErrNormal)
51
return
@@ -58,7 +58,7 @@ var queryDhtCmd = &cmds.Command{
58
}
59
60
events := make(chan *notif.QueryEvent)
61
- ctx := notif.RegisterForQueryEvents(req.Context().Context, events)
61
+ ctx := notif.RegisterForQueryEvents(req.Context(), events)
62
63
closestPeers, err := dht.GetClosestPeers(ctx, key.Key(req.Arguments()[0]))
64
if err != nil {
@@ -152,7 +152,7 @@ FindProviders will return a list of peers who are able to provide the value requ
152
cmds.BoolOption("verbose", "v", "Write extra information"),
153
},
154
Run: func(req cmds.Request, res cmds.Response) {
155
- n, err := req.Context().GetNode()
155
+ n, err := req.InvocContext().GetNode()
156
if err != nil {
157
res.SetError(err, cmds.ErrNormal)
158
return
@@ -170,7 +170,7 @@ FindProviders will return a list of peers who are able to provide the value requ
170
res.SetOutput((<-chan interface{})(outChan))
171
172
events := make(chan *notif.QueryEvent)
173
- ctx := notif.RegisterForQueryEvents(req.Context().Context, events)
173
+ ctx := notif.RegisterForQueryEvents(req.Context(), events)
174
175
pchan := dht.FindProvidersAsync(ctx, key.B58KeyDecode(req.Arguments()[0]), numProviders)
176
go func() {
@@ -265,7 +265,7 @@ var findPeerDhtCmd = &cmds.Command{
265
cmds.StringArg("peerID", true, true, "The peer to search for"),
266
},
267
Run: func(req cmds.Request, res cmds.Response) {
268
- n, err := req.Context().GetNode()
268
+ n, err := req.InvocContext().GetNode()
269
if err != nil {
270
res.SetError(err, cmds.ErrNormal)
271
return
@@ -287,7 +287,7 @@ var findPeerDhtCmd = &cmds.Command{
287
res.SetOutput((<-chan interface{})(outChan))
288
289
events := make(chan *notif.QueryEvent)
290
- ctx := notif.RegisterForQueryEvents(req.Context().Context, events)
290
+ ctx := notif.RegisterForQueryEvents(req.Context(), events)
291
292
go func() {
293
defer close(outChan)
@@ -375,7 +375,7 @@ GetValue will return the value stored in the dht at the given key.
375
cmds.BoolOption("verbose", "v", "Write extra information"),
376
},
377
Run: func(req cmds.Request, res cmds.Response) {
378
- n, err := req.Context().GetNode()
378
+ n, err := req.InvocContext().GetNode()
379
if err != nil {
380
res.SetError(err, cmds.ErrNormal)
381
return
@@ -391,7 +391,7 @@ GetValue will return the value stored in the dht at the given key.
391
res.SetOutput((<-chan interface{})(outChan))
392
393
events := make(chan *notif.QueryEvent)
394
- ctx := notif.RegisterForQueryEvents(req.Context().Context, events)
394
+ ctx := notif.RegisterForQueryEvents(req.Context(), events)
395
396
go func() {
397
defer close(outChan)
@@ -483,7 +483,7 @@ PutValue will store the given key value pair in the dht.
483
cmds.BoolOption("verbose", "v", "Write extra information"),
484
},
485
Run: func(req cmds.Request, res cmds.Response) {
486
- n, err := req.Context().GetNode()
486
+ n, err := req.InvocContext().GetNode()
487
if err != nil {
488
res.SetError(err, cmds.ErrNormal)
489
return
@@ -499,7 +499,7 @@ PutValue will store the given key value pair in the dht.
499
res.SetOutput((<-chan interface{})(outChan))
500
501
events := make(chan *notif.QueryEvent)
502
- ctx := notif.RegisterForQueryEvents(req.Context().Context, events)
502
+ ctx := notif.RegisterForQueryEvents(req.Context(), events)
503
504
key := key.B58KeyDecode(req.Arguments()[0])
505
data := req.Arguments()[1]
core/commands/diag.go
+1
-1
@@ -90,7 +90,7 @@ that consume the dot format to generate graphs of the network.
90
},
91
92
Run: func(req cmds.Request, res cmds.Response) {
93
- n, err := req.Context().GetNode()
93
+ n, err := req.InvocContext().GetNode()
94
if err != nil {
95
res.SetError(err, cmds.ErrNormal)
96
return
core/commands/dns.go
+1
-1
@@ -62,7 +62,7 @@ The resolver will give:
62
if recursive {
63
depth = namesys.DefaultDepthLimit
64
}
65
- output, err := resolver.ResolveN(req.Context().Context, name, depth)
65
+ output, err := resolver.ResolveN(req.Context(), name, depth)
66
if err != nil {
67
res.SetError(err, cmds.ErrNormal)
68
return
core/commands/get.go
+3
-3
@@ -59,7 +59,7 @@ may also specify the level of compression by specifying '-l=<1-9>'.
59
return
60
}
61
62
- node, err := req.Context().GetNode()
62
+ node, err := req.InvocContext().GetNode()
63
if err != nil {
64
res.SetError(err, cmds.ErrNormal)
65
return
@@ -69,9 +69,9 @@ may also specify the level of compression by specifying '-l=<1-9>'.
69
var reader io.Reader
70
if archive, _, _ := req.Option("archive").Bool(); !archive && cmplvl != gzip.NoCompression {
71
// only use this when the flag is '-C' without '-a'
72
- reader, err = getZip(req.Context().Context, node, p, cmplvl)
72
+ reader, err = getZip(req.Context(), node, p, cmplvl)
73
} else {
74
- reader, err = get(req.Context().Context, node, p, cmplvl)
74
+ reader, err = get(req.Context(), node, p, cmplvl)
75
}
76
if err != nil {
77
res.SetError(err, cmds.ErrNormal)
core/commands/id.go
+2
-2
@@ -56,7 +56,7 @@ ipfs id supports the format option for output with the following keys:
56
cmds.StringOption("f", "format", "optional output format"),
57
},
58
Run: func(req cmds.Request, res cmds.Response) {
59
- node, err := req.Context().GetNode()
59
+ node, err := req.InvocContext().GetNode()
60
if err != nil {
61
res.SetError(err, cmds.ErrNormal)
62
return
@@ -86,7 +86,7 @@ ipfs id supports the format option for output with the following keys:
86
return
87
}
88
89
- p, err := node.Routing.FindPeer(req.Context().Context, id)
89
+ p, err := node.Routing.FindPeer(req.Context(), id)
90
if err == kb.ErrLookupFailure {
91
res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient)
92
return
core/commands/ipns.go
+2
-2
@@ -47,7 +47,7 @@ Resolve the value of another name:
47
},
48
Run: func(req cmds.Request, res cmds.Response) {
49
50
- n, err := req.Context().GetNode()
50
+ n, err := req.InvocContext().GetNode()
51
if err != nil {
52
res.SetError(err, cmds.ErrNormal)
53
return
@@ -81,7 +81,7 @@ Resolve the value of another name:
81
}
82
83
resolver := namesys.NewRoutingResolver(n.Routing)
84
- output, err := resolver.ResolveN(n.Context(), name, depth)
84
+ output, err := resolver.ResolveN(req.Context(), name, depth)
85
if err != nil {
86
res.SetError(err, cmds.ErrNormal)
87
return
core/commands/log.go
+2
-2
@@ -80,7 +80,7 @@ var logTailCmd = &cmds.Command{
80
},
81
82
Run: func(req cmds.Request, res cmds.Response) {
83
- path := fmt.Sprintf("%s/logs/events.log", req.Context().ConfigRoot)
83
+ path := fmt.Sprintf("%s/logs/events.log", req.InvocContext().ConfigRoot)
84
85
outChan := make(chan interface{})
86
@@ -99,7 +99,7 @@ var logTailCmd = &cmds.Command{
99
}
100
defer t.Stop()
101
102
- done := req.Context().Context.Done()
102
+ done := req.Context().Done()
103
104
for line := range t.Lines {
105
// return when context closes
core/commands/ls.go
+3
-3
@@ -50,7 +50,7 @@ it contains, with the following format:
50
cmds.BoolOption("headers", "", "Print table headers (Hash, Name, Size)"),
51
},
52
Run: func(req cmds.Request, res cmds.Response) {
53
- node, err := req.Context().GetNode()
53
+ node, err := req.InvocContext().GetNode()
54
if err != nil {
55
res.SetError(err, cmds.ErrNormal)
56
return
@@ -66,7 +66,7 @@ it contains, with the following format:
66
67
var dagnodes []*merkledag.Node
68
for _, fpath := range paths {
69
- dagnode, err := core.Resolve(req.Context().Context, node, path.Path(fpath))
69
+ dagnode, err := core.Resolve(req.Context(), node, path.Path(fpath))
70
if err != nil {
71
res.SetError(err, cmds.ErrNormal)
72
return
@@ -81,7 +81,7 @@ it contains, with the following format:
81
Links: make([]LsLink, len(dagnode.Links)),
82
}
83
for j, link := range dagnode.Links {
84
- ctx, cancel := context.WithTimeout(req.Context().Context, time.Minute)
84
+ ctx, cancel := context.WithTimeout(req.Context(), time.Minute)
85
defer cancel()
86
link.Node, err = link.GetNode(ctx, node.DAG)
87
if err != nil {
core/commands/mount_unix.go
+2
-2
@@ -97,13 +97,13 @@ baz
97
cmds.StringOption("ipns-path", "n", "The path where IPNS should be mounted"),
98
},
99
Run: func(req cmds.Request, res cmds.Response) {
100
- cfg, err := req.Context().GetConfig()
100
+ cfg, err := req.InvocContext().GetConfig()
101
if err != nil {
102
res.SetError(err, cmds.ErrNormal)
103
return
104
}
105
106
- node, err := req.Context().GetNode()
106
+ node, err := req.InvocContext().GetNode()
107
if err != nil {
108
res.SetError(err, cmds.ErrNormal)
109
return
core/commands/object.go
+17
-17
@@ -93,14 +93,14 @@ output is the raw data of the object.
93
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format").EnableStdin(),
94
},
95
Run: func(req cmds.Request, res cmds.Response) {
96
- n, err := req.Context().GetNode()
96
+ n, err := req.InvocContext().GetNode()
97
if err != nil {
98
res.SetError(err, cmds.ErrNormal)
99
return
100
}
101
102
fpath := path.Path(req.Arguments()[0])
103
- node, err := core.Resolve(req.Context().Context, n, fpath)
103
+ node, err := core.Resolve(req.Context(), n, fpath)
104
if err != nil {
105
res.SetError(err, cmds.ErrNormal)
106
return
@@ -123,14 +123,14 @@ multihash.
123
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format").EnableStdin(),
124
},
125
Run: func(req cmds.Request, res cmds.Response) {
126
- n, err := req.Context().GetNode()
126
+ n, err := req.InvocContext().GetNode()
127
if err != nil {
128
res.SetError(err, cmds.ErrNormal)
129
return
130
}
131
132
fpath := path.Path(req.Arguments()[0])
133
- node, err := core.Resolve(req.Context().Context, n, fpath)
133
+ node, err := core.Resolve(req.Context(), n, fpath)
134
if err != nil {
135
res.SetError(err, cmds.ErrNormal)
136
return
@@ -182,7 +182,7 @@ This command outputs data in the following encodings:
182
cmds.StringArg("key", true, false, "Key of the object to retrieve (in base58-encoded multihash format)").EnableStdin(),
183
},
184
Run: func(req cmds.Request, res cmds.Response) {
185
- n, err := req.Context().GetNode()
185
+ n, err := req.InvocContext().GetNode()
186
if err != nil {
187
res.SetError(err, cmds.ErrNormal)
188
return
@@ -190,7 +190,7 @@ This command outputs data in the following encodings:
190
191
fpath := path.Path(req.Arguments()[0])
192
193
- object, err := core.Resolve(req.Context().Context, n, fpath)
193
+ object, err := core.Resolve(req.Context(), n, fpath)
194
if err != nil {
195
res.SetError(err, cmds.ErrNormal)
196
return
@@ -248,7 +248,7 @@ var objectStatCmd = &cmds.Command{
248
cmds.StringArg("key", true, false, "Key of the object to retrieve (in base58-encoded multihash format)").EnableStdin(),
249
},
250
Run: func(req cmds.Request, res cmds.Response) {
251
- n, err := req.Context().GetNode()
251
+ n, err := req.InvocContext().GetNode()
252
if err != nil {
253
res.SetError(err, cmds.ErrNormal)
254
return
@@ -256,7 +256,7 @@ var objectStatCmd = &cmds.Command{
256
257
fpath := path.Path(req.Arguments()[0])
258
259
- object, err := core.Resolve(req.Context().Context, n, fpath)
259
+ object, err := core.Resolve(req.Context(), n, fpath)
260
if err != nil {
261
res.SetError(err, cmds.ErrNormal)
262
return
@@ -335,7 +335,7 @@ and then run
335
cmds.StringOption("inputenc", "Encoding type of input data, either \"protobuf\" or \"json\""),
336
},
337
Run: func(req cmds.Request, res cmds.Response) {
338
- n, err := req.Context().GetNode()
338
+ n, err := req.InvocContext().GetNode()
339
if err != nil {
340
res.SetError(err, cmds.ErrNormal)
341
return
@@ -397,7 +397,7 @@ Available templates:
397
cmds.StringArg("template", false, false, "optional template to use"),
398
},
399
Run: func(req cmds.Request, res cmds.Response) {
400
- n, err := req.Context().GetNode()
400
+ n, err := req.InvocContext().GetNode()
401
if err != nil {
402
res.SetError(err, cmds.ErrNormal)
403
return
@@ -461,7 +461,7 @@ resulting object hash.
461
},
462
Type: Object{},
463
Run: func(req cmds.Request, res cmds.Response) {
464
- nd, err := req.Context().GetNode()
464
+ nd, err := req.InvocContext().GetNode()
465
if err != nil {
466
res.SetError(err, cmds.ErrNormal)
467
return
@@ -473,7 +473,7 @@ resulting object hash.
473
return
474
}
475
476
- ctx, cancel := context.WithTimeout(req.Context().Context, time.Second*30)
476
+ ctx, cancel := context.WithTimeout(req.Context(), time.Second*30)
477
rnode, err := nd.DAG.Get(ctx, rhash)
478
if err != nil {
479
res.SetError(err, cmds.ErrNormal)
@@ -535,7 +535,7 @@ func appendDataCaller(req cmds.Request, root *dag.Node) (key.Key, error) {
535
return "", fmt.Errorf("not enough arguments for set-data")
536
}
537
538
- nd, err := req.Context().GetNode()
538
+ nd, err := req.InvocContext().GetNode()
539
if err != nil {
540
return "", err
541
}
@@ -555,7 +555,7 @@ func setDataCaller(req cmds.Request, root *dag.Node) (key.Key, error) {
555
return "", fmt.Errorf("not enough arguments for set-data")
556
}
557
558
- nd, err := req.Context().GetNode()
558
+ nd, err := req.InvocContext().GetNode()
559
if err != nil {
560
return "", err
561
}
@@ -575,7 +575,7 @@ func rmLinkCaller(req cmds.Request, root *dag.Node) (key.Key, error) {
575
return "", fmt.Errorf("not enough arguments for rm-link")
576
}
577
578
- nd, err := req.Context().GetNode()
578
+ nd, err := req.InvocContext().GetNode()
579
if err != nil {
580
return "", err
581
}
@@ -600,7 +600,7 @@ func addLinkCaller(req cmds.Request, root *dag.Node) (key.Key, error) {
600
return "", fmt.Errorf("not enough arguments for add-link")
601
}
602
603
- nd, err := req.Context().GetNode()
603
+ nd, err := req.InvocContext().GetNode()
604
if err != nil {
605
return "", err
606
}
@@ -610,7 +610,7 @@ func addLinkCaller(req cmds.Request, root *dag.Node) (key.Key, error) {
610
611
parts := strings.Split(path, "/")
612
613
- nnode, err := insertNodeAtPath(req.Context().Context, nd.DAG, root, parts, childk)
613
+ nnode, err := insertNodeAtPath(req.Context(), nd.DAG, root, parts, childk)
614
if err != nil {
615
return "", err
616
}
core/commands/pin.go
+6
-6
@@ -44,7 +44,7 @@ on disk.
44
},
45
Type: PinOutput{},
46
Run: func(req cmds.Request, res cmds.Response) {
47
- n, err := req.Context().GetNode()
47
+ n, err := req.InvocContext().GetNode()
48
if err != nil {
49
res.SetError(err, cmds.ErrNormal)
50
return
@@ -61,11 +61,11 @@ on disk.
61
}
62
63
go func() {
64
- <-req.Context().Context.Done()
64
+ <-req.Context().Done()
65
log.Error("CONTEXT IS OVER!")
66
}()
67
68
- added, err := corerepo.Pin(n, req.Context().Context, req.Arguments(), recursive)
68
+ added, err := corerepo.Pin(n, req.Context(), req.Arguments(), recursive)
69
if err != nil {
70
res.SetError(err, cmds.ErrNormal)
71
return
@@ -114,7 +114,7 @@ collected if needed.
114
},
115
Type: PinOutput{},
116
Run: func(req cmds.Request, res cmds.Response) {
117
- n, err := req.Context().GetNode()
117
+ n, err := req.InvocContext().GetNode()
118
if err != nil {
119
res.SetError(err, cmds.ErrNormal)
120
return
@@ -130,7 +130,7 @@ collected if needed.
130
recursive = false // default
131
}
132
133
- removed, err := corerepo.Unpin(n, req.Context().Context, req.Arguments(), recursive)
133
+ removed, err := corerepo.Unpin(n, req.Context(), req.Arguments(), recursive)
134
if err != nil {
135
res.SetError(err, cmds.ErrNormal)
136
return
@@ -182,7 +182,7 @@ Defaults to "direct".
182
cmds.BoolOption("quiet", "q", "Write just hashes of objects"),
183
},
184
Run: func(req cmds.Request, res cmds.Response) {
185
- n, err := req.Context().GetNode()
185
+ n, err := req.InvocContext().GetNode()
186
if err != nil {
187
res.SetError(err, cmds.ErrNormal)
188
return
core/commands/ping.go
+2
-2
@@ -75,8 +75,8 @@ trip latency information.
75
},
76
},
77
Run: func(req cmds.Request, res cmds.Response) {
78
- ctx := req.Context().Context
79
- n, err := req.Context().GetNode()
78
+ ctx := req.Context()
79
+ n, err := req.InvocContext().GetNode()
80
if err != nil {
81
res.SetError(err, cmds.ErrNormal)
82
return
core/commands/publish.go
+2
-2
@@ -51,7 +51,7 @@ Publish an <ipfs-path> to another public key (not implemented):
51
},
52
Run: func(req cmds.Request, res cmds.Response) {
53
log.Debug("Begin Publish")
54
- n, err := req.Context().GetNode()
54
+ n, err := req.InvocContext().GetNode()
55
if err != nil {
56
res.SetError(err, cmds.ErrNormal)
57
return
@@ -90,7 +90,7 @@ Publish an <ipfs-path> to another public key (not implemented):
90
91
// TODO n.Keychain.Get(name).PrivKey
92
// TODO(cryptix): is req.Context().Context a child of n.Context()?
93
- output, err := publish(req.Context().Context, n, n.PrivateKey, path.Path(pstr))
93
+ output, err := publish(req.Context(), n, n.PrivateKey, path.Path(pstr))
94
if err != nil {
95
res.SetError(err, cmds.ErrNormal)
96
return
core/commands/refs.go
+4
-4
@@ -56,8 +56,8 @@ Note: list all refs recursively with -r.
56
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes"),
57
},
58
Run: func(req cmds.Request, res cmds.Response) {
59
- ctx := req.Context().Context
60
- n, err := req.Context().GetNode()
59
+ ctx := req.Context()
60
+ n, err := req.InvocContext().GetNode()
61
if err != nil {
62
res.SetError(err, cmds.ErrNormal)
63
return
@@ -156,8 +156,8 @@ Displays the hashes of all local objects.
156
},
157
158
Run: func(req cmds.Request, res cmds.Response) {
159
- ctx := req.Context().Context
160
- n, err := req.Context().GetNode()
159
+ ctx := req.Context()
160
+ n, err := req.InvocContext().GetNode()
161
if err != nil {
162
res.SetError(err, cmds.ErrNormal)
163
return
core/commands/repo.go
+2
-2
@@ -37,13 +37,13 @@ order to reclaim hard disk space.
37
cmds.BoolOption("quiet", "q", "Write minimal output"),
38
},
39
Run: func(req cmds.Request, res cmds.Response) {
40
- n, err := req.Context().GetNode()
40
+ n, err := req.InvocContext().GetNode()
41
if err != nil {
42
res.SetError(err, cmds.ErrNormal)
43
return
44
}
45
46
- gcOutChan, err := corerepo.GarbageCollectAsync(n, req.Context().Context)
46
+ gcOutChan, err := corerepo.GarbageCollectAsync(n, req.Context())
47
if err != nil {
48
res.SetError(err, cmds.ErrNormal)
49
return
core/commands/resolve.go
+2
-2
@@ -57,7 +57,7 @@ Resolve the value of another name recursively:
57
},
58
Run: func(req cmds.Request, res cmds.Response) {
59
60
- n, err := req.Context().GetNode()
60
+ n, err := req.InvocContext().GetNode()
61
if err != nil {
62
res.SetError(err, cmds.ErrNormal)
63
return
@@ -78,7 +78,7 @@ Resolve the value of another name recursively:
78
depth = namesys.DefaultDepthLimit
79
}
80
81
- output, err := n.Namesys.ResolveN(n.Context(), name, depth)
81
+ output, err := n.Namesys.ResolveN(req.Context(), name, depth)
82
if err != nil {
83
res.SetError(err, cmds.ErrNormal)
84
return
core/commands/stat.go
+2
-2
@@ -40,7 +40,7 @@ var statBwCmd = &cmds.Command{
40
},
41
42
Run: func(req cmds.Request, res cmds.Response) {
43
- nd, err := req.Context().GetNode()
43
+ nd, err := req.InvocContext().GetNode()
44
if err != nil {
45
res.SetError(err, cmds.ErrNormal)
46
return
@@ -121,7 +121,7 @@ var statBwCmd = &cmds.Command{
121
}
122
select {
123
case <-time.After(interval):
124
- case <-req.Context().Context.Done():
124
+ case <-req.Context().Done():
125
return
126
}
127
}
core/commands/swarm.go
+8
-8
@@ -61,7 +61,7 @@ ipfs swarm peers lists the set of peers this node is connected to.
61
Run: func(req cmds.Request, res cmds.Response) {
62
63
log.Debug("ipfs swarm peers")
64
- n, err := req.Context().GetNode()
64
+ n, err := req.InvocContext().GetNode()
65
if err != nil {
66
res.SetError(err, cmds.ErrNormal)
67
return
@@ -101,7 +101,7 @@ ipfs swarm addrs lists all addresses this node is aware of.
101
},
102
Run: func(req cmds.Request, res cmds.Response) {
103
104
- n, err := req.Context().GetNode()
104
+ n, err := req.InvocContext().GetNode()
105
if err != nil {
106
res.SetError(err, cmds.ErrNormal)
107
return
@@ -164,7 +164,7 @@ ipfs swarm addrs local lists all local addresses the node is listening on.
164
},
165
Run: func(req cmds.Request, res cmds.Response) {
166
167
- n, err := req.Context().GetNode()
167
+ n, err := req.InvocContext().GetNode()
168
if err != nil {
169
res.SetError(err, cmds.ErrNormal)
170
return
@@ -213,7 +213,7 @@ ipfs swarm connect /ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3
213
Run: func(req cmds.Request, res cmds.Response) {
214
ctx := context.TODO()
215
216
- n, err := req.Context().GetNode()
216
+ n, err := req.InvocContext().GetNode()
217
if err != nil {
218
res.SetError(err, cmds.ErrNormal)
219
return
@@ -266,7 +266,7 @@ ipfs swarm disconnect /ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQA
266
cmds.StringArg("address", true, true, "address of peer to connect to").EnableStdin(),
267
},
268
Run: func(req cmds.Request, res cmds.Response) {
269
- n, err := req.Context().GetNode()
269
+ n, err := req.InvocContext().GetNode()
270
if err != nil {
271
res.SetError(err, cmds.ErrNormal)
272
return
@@ -386,7 +386,7 @@ Filters default to those specified under the "Swarm.AddrFilters" config key.
386
"rm": swarmFiltersRmCmd,
387
},
388
Run: func(req cmds.Request, res cmds.Response) {
389
- n, err := req.Context().GetNode()
389
+ n, err := req.InvocContext().GetNode()
390
if err != nil {
391
res.SetError(err, cmds.ErrNormal)
392
return
@@ -433,7 +433,7 @@ add your filters to the ipfs config file.
433
cmds.StringArg("address", true, true, "multiaddr to filter").EnableStdin(),
434
},
435
Run: func(req cmds.Request, res cmds.Response) {
436
- n, err := req.Context().GetNode()
436
+ n, err := req.InvocContext().GetNode()
437
if err != nil {
438
res.SetError(err, cmds.ErrNormal)
439
return
@@ -475,7 +475,7 @@ remove your filters from the ipfs config file.
475
cmds.StringArg("address", true, true, "multiaddr filter to remove").EnableStdin(),
476
},
477
Run: func(req cmds.Request, res cmds.Response) {
478
- n, err := req.Context().GetNode()
478
+ n, err := req.InvocContext().GetNode()
479
if err != nil {
480
res.SetError(err, cmds.ErrNormal)
481
return
core/commands/tour.go
+6
-6
@@ -37,7 +37,7 @@ IPFS very quickly. To start, run:
37
38
func tourRunFunc(req cmds.Request, res cmds.Response) {
39
40
- cfg, err := req.Context().GetConfig()
40
+ cfg, err := req.InvocContext().GetConfig()
41
if err != nil {
42
res.SetError(err, cmds.ErrNormal)
43
return
@@ -78,8 +78,8 @@ var cmdIpfsTourNext = &cmds.Command{
78
79
Run: func(req cmds.Request, res cmds.Response) {
80
w := new(bytes.Buffer)
81
- path := req.Context().ConfigRoot
82
- cfg, err := req.Context().GetConfig()
81
+ path := req.InvocContext().ConfigRoot
82
+ cfg, err := req.InvocContext().GetConfig()
83
if err != nil {
84
res.SetError(err, cmds.ErrNormal)
85
return
@@ -116,8 +116,8 @@ var cmdIpfsTourRestart = &cmds.Command{
116
},
117
118
Run: func(req cmds.Request, res cmds.Response) {
119
- path := req.Context().ConfigRoot
120
- cfg, err := req.Context().GetConfig()
119
+ path := req.InvocContext().ConfigRoot
120
+ cfg, err := req.InvocContext().GetConfig()
121
if err != nil {
122
res.SetError(err, cmds.ErrNormal)
123
return
@@ -138,7 +138,7 @@ var cmdIpfsTourList = &cmds.Command{
138
},
139
140
Run: func(req cmds.Request, res cmds.Response) {
141
- cfg, err := req.Context().GetConfig()
141
+ cfg, err := req.InvocContext().GetConfig()
142
if err != nil {
143
res.SetError(err, cmds.ErrNormal)
144
return
core/commands/unixfs/ls.go
+2
-2
@@ -52,7 +52,7 @@ size is the IPFS link size.
52
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from").EnableStdin(),
53
},
54
Run: func(req cmds.Request, res cmds.Response) {
55
- node, err := req.Context().GetNode()
55
+ node, err := req.InvocContext().GetNode()
56
if err != nil {
57
res.SetError(err, cmds.ErrNormal)
58
return
@@ -66,7 +66,7 @@ size is the IPFS link size.
66
}
67
68
for _, fpath := range paths {
69
- ctx := req.Context().Context
69
+ ctx := req.Context()
70
merkleNode, err := core.Resolve(ctx, node, path.Path(fpath))
71
if err != nil {
72
res.SetError(err, cmds.ErrNormal)
core/commands/update.go
+3
-3
@@ -33,7 +33,7 @@ var updateCmd = &cmds.Command{
33
},
34
35
Run: func(req cmds.Request, res cmds.Response) {
36
- n, err := req.Context().GetNode()
36
+ n, err := req.InvocContext().GetNode()
37
if err != nil {
38
res.SetError(err, cmds.ErrNormal)
39
return
@@ -73,7 +73,7 @@ var UpdateCheckCmd = &cmds.Command{
73
},
74
75
Run: func(req cmds.Request, res cmds.Response) {
76
- n, err := req.Context().GetNode()
76
+ n, err := req.InvocContext().GetNode()
77
if err != nil {
78
res.SetError(err, cmds.ErrNormal)
79
return
@@ -109,7 +109,7 @@ var UpdateLogCmd = &cmds.Command{
109
},
110
111
Run: func(req cmds.Request, res cmds.Response) {
112
- n, err := req.Context().GetNode()
112
+ n, err := req.InvocContext().GetNode()
113
if err != nil {
114
res.SetError(err, cmds.ErrNormal)
115
return
test/supernode_client/main.go
-2
@@ -233,8 +233,6 @@ func toPeerInfo(bootstrap config.BootstrapPeer) (p peer.PeerInfo, err error) {
233
234
func cmdCtx(node *core.IpfsNode, repoPath string) commands.Context {
235
return commands.Context{
236
- // TODO deprecate this shit
237
- Context: context.Background(),
236
Online: true,
237
ConfigRoot: repoPath,
238
LoadConfig: func(path string) (*config.Config, error) {