提交 8082af79 作者: Kevin Atkinson 提交者: Jeromy

Use buffered channels in AllKeysChan to increase performance.

License: MIT
Signed-off-by: 's avatarKevin Atkinson <k@kevina.org>
上级 8e1a03dd
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/ipfs/go-ipfs/blocks/blockstore" "github.com/ipfs/go-ipfs/blocks/blockstore"
posinfo "github.com/ipfs/go-ipfs/thirdparty/posinfo" posinfo "github.com/ipfs/go-ipfs/thirdparty/posinfo"
dsq "gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/query"
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
) )
...@@ -30,7 +31,7 @@ func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) { ...@@ -30,7 +31,7 @@ func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) {
return nil, err return nil, err
} }
out := make(chan *cid.Cid) out := make(chan *cid.Cid, dsq.KeysOnlyBufSize)
go func() { go func() {
defer cancel() defer cancel()
defer close(out) defer close(out)
......
...@@ -48,7 +48,7 @@ func (f *FileManager) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) ...@@ -48,7 +48,7 @@ func (f *FileManager) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
return nil, err return nil, err
} }
out := make(chan *cid.Cid) out := make(chan *cid.Cid, dsq.KeysOnlyBufSize)
go func() { go func() {
defer close(out) defer close(out)
for { for {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论