Skip to content

Commit

Permalink
refs: tie the contexts together
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenet committed Jan 12, 2015
1 parent 322d6d0 commit 374a75b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions blocks/blockstore/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (<

// need to convert to u.Key using u.KeyFromDsKey.
k = u.KeyFromDsKey(ds.NewKey(e.Key))
log.Debug("blockstore: query got key", k)
return k, true
}
}
Expand Down
8 changes: 5 additions & 3 deletions core/commands/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Note: list all refs recursively with -r.
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes"),
},
Run: func(req cmds.Request) (interface{}, error) {
ctx := req.Context().Context
n, err := req.Context().GetNode()
if err != nil {
return nil, err
Expand Down Expand Up @@ -93,7 +94,7 @@ Note: list all refs recursively with -r.
rw := RefWriter{
W: pipew,
DAG: n.DAG,
Ctx: n.Context(),
Ctx: ctx,
Unique: unique,
PrintEdge: edges,
PrintFmt: format,
Expand Down Expand Up @@ -122,13 +123,14 @@ Displays the hashes of all local objects.
},

Run: func(req cmds.Request) (interface{}, error) {
ctx := req.Context().Context
n, err := req.Context().GetNode()
if err != nil {
return nil, err
}

// todo: make async
allKeys, err := n.Blockstore.AllKeys(context.TODO(), 0, 0)
allKeys, err := n.Blockstore.AllKeysChan(ctx, 0, 0)
if err != nil {
return nil, err
}
Expand All @@ -139,7 +141,7 @@ Displays the hashes of all local objects.
go func() {
defer pipew.Close()

for _, k := range allKeys {
for k := range allKeys {
s := k.Pretty() + "\n"
if _, err := pipew.Write([]byte(s)); err != nil {
log.Error(err)
Expand Down

0 comments on commit 374a75b

Please sign in to comment.