refs: tie the contexts together
Juan Batiz-Benet committed
Jan 10, 2015 at 20:44 UTC
374a75b61203f956ca008851fba7205ddf113813
2 files changed
+6
-3
blocks/blockstore/blockstore.go
+1
@@ -132,6 +132,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (<
132
133
// need to convert to u.Key using u.KeyFromDsKey.
134
k = u.KeyFromDsKey(ds.NewKey(e.Key))
135
+ log.Debug("blockstore: query got key", k)
136
return k, true
137
}
138
}
core/commands/refs.go
+5
-3
@@ -54,6 +54,7 @@ Note: list all refs recursively with -r.
54
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes"),
55
},
56
Run: func(req cmds.Request) (interface{}, error) {
57
+ ctx := req.Context().Context
58
n, err := req.Context().GetNode()
59
if err != nil {
60
return nil, err
@@ -93,7 +94,7 @@ Note: list all refs recursively with -r.
94
rw := RefWriter{
95
W: pipew,
96
DAG: n.DAG,
96
- Ctx: n.Context(),
97
+ Ctx: ctx,
98
Unique: unique,
99
PrintEdge: edges,
100
PrintFmt: format,
@@ -122,13 +123,14 @@ Displays the hashes of all local objects.
123
},
124
125
Run: func(req cmds.Request) (interface{}, error) {
126
+ ctx := req.Context().Context
127
n, err := req.Context().GetNode()
128
if err != nil {
129
return nil, err
130
}
131
132
// todo: make async
131
- allKeys, err := n.Blockstore.AllKeys(context.TODO(), 0, 0)
133
+ allKeys, err := n.Blockstore.AllKeysChan(ctx, 0, 0)
134
if err != nil {
135
return nil, err
136
}
@@ -139,7 +141,7 @@ Displays the hashes of all local objects.
141
go func() {
142
defer pipew.Close()
143
142
- for _, k := range allKeys {
144
+ for k := range allKeys {
145
s := k.Pretty() + "\n"
146
if _, err := pipew.Write([]byte(s)); err != nil {
147
log.Error(err)