Commit 374a75b6 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

refs: tie the contexts together

parent 322d6d0b
...@@ -132,6 +132,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (< ...@@ -132,6 +132,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (<
// need to convert to u.Key using u.KeyFromDsKey. // need to convert to u.Key using u.KeyFromDsKey.
k = u.KeyFromDsKey(ds.NewKey(e.Key)) k = u.KeyFromDsKey(ds.NewKey(e.Key))
log.Debug("blockstore: query got key", k)
return k, true return k, true
} }
} }
......
...@@ -54,6 +54,7 @@ Note: list all refs recursively with -r. ...@@ -54,6 +54,7 @@ Note: list all refs recursively with -r.
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes"), cmds.BoolOption("recursive", "r", "Recursively list links of child nodes"),
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
ctx := req.Context().Context
n, err := req.Context().GetNode() n, err := req.Context().GetNode()
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -93,7 +94,7 @@ Note: list all refs recursively with -r. ...@@ -93,7 +94,7 @@ Note: list all refs recursively with -r.
rw := RefWriter{ rw := RefWriter{
W: pipew, W: pipew,
DAG: n.DAG, DAG: n.DAG,
Ctx: n.Context(), Ctx: ctx,
Unique: unique, Unique: unique,
PrintEdge: edges, PrintEdge: edges,
PrintFmt: format, PrintFmt: format,
...@@ -122,13 +123,14 @@ Displays the hashes of all local objects. ...@@ -122,13 +123,14 @@ Displays the hashes of all local objects.
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
ctx := req.Context().Context
n, err := req.Context().GetNode() n, err := req.Context().GetNode()
if err != nil { if err != nil {
return nil, err return nil, err
} }
// todo: make async // todo: make async
allKeys, err := n.Blockstore.AllKeys(context.TODO(), 0, 0) allKeys, err := n.Blockstore.AllKeysChan(ctx, 0, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -139,7 +141,7 @@ Displays the hashes of all local objects. ...@@ -139,7 +141,7 @@ Displays the hashes of all local objects.
go func() { go func() {
defer pipew.Close() defer pipew.Close()
for _, k := range allKeys { for k := range allKeys {
s := k.Pretty() + "\n" s := k.Pretty() + "\n"
if _, err := pipew.Write([]byte(s)); err != nil { if _, err := pipew.Write([]byte(s)); err != nil {
log.Error(err) log.Error(err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment