Skip to content

Commit

Permalink
Use buffered channels in AllKeysChan to increase performance.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina authored and whyrusleeping committed Mar 2, 2017
1 parent 93ec38d commit 1a94991
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion filestore/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ipfs/go-ipfs/blocks/blockstore"
posinfo "github.com/ipfs/go-ipfs/thirdparty/posinfo"

dsq "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/query"
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
cid "gx/ipfs/QmcTcsTvfaeEBRFo1TkFgT8sRmgi1n1LTZpecfVP8fzpGD/go-cid"
)
Expand All @@ -30,7 +31,7 @@ func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) {
return nil, err
}

out := make(chan *cid.Cid)
out := make(chan *cid.Cid, dsq.KeysOnlyBufSize)
go func() {
defer cancel()
defer close(out)
Expand Down
2 changes: 1 addition & 1 deletion filestore/fsrefstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (f *FileManager) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
return nil, err
}

out := make(chan *cid.Cid)
out := make(chan *cid.Cid, dsq.KeysOnlyBufSize)
go func() {
defer close(out)
for {
Expand Down

0 comments on commit 1a94991

Please sign in to comment.