Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
63c25285
提交
63c25285
authored
3月 11, 2015
作者:
Tommi Virtanen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dead code cleanup: remove AllKeys from blockstore
Nothing uses it.
上级
1a48e6a9
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
13 行增加
和
25 行删除
+13
-25
blockstore.go
blocks/blockstore/blockstore.go
+0
-19
blockstore_test.go
blocks/blockstore/blockstore_test.go
+13
-2
write_cache.go
blocks/blockstore/write_cache.go
+0
-4
没有找到文件。
blocks/blockstore/blockstore.go
浏览文件 @
63c25285
...
@@ -31,7 +31,6 @@ type Blockstore interface {
...
@@ -31,7 +31,6 @@ type Blockstore interface {
Get
(
u
.
Key
)
(
*
blocks
.
Block
,
error
)
Get
(
u
.
Key
)
(
*
blocks
.
Block
,
error
)
Put
(
*
blocks
.
Block
)
error
Put
(
*
blocks
.
Block
)
error
AllKeys
(
ctx
context
.
Context
)
([]
u
.
Key
,
error
)
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
u
.
Key
,
error
)
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
u
.
Key
,
error
)
}
}
...
@@ -82,24 +81,6 @@ func (s *blockstore) DeleteBlock(k u.Key) error {
...
@@ -82,24 +81,6 @@ func (s *blockstore) DeleteBlock(k u.Key) error {
return
s
.
datastore
.
Delete
(
k
.
DsKey
())
return
s
.
datastore
.
Delete
(
k
.
DsKey
())
}
}
// AllKeys runs a query for keys from the blockstore.
// this is very simplistic, in the future, take dsq.Query as a param?
//
// AllKeys respects context
func
(
bs
*
blockstore
)
AllKeys
(
ctx
context
.
Context
)
([]
u
.
Key
,
error
)
{
ch
,
err
:=
bs
.
AllKeysChan
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
var
keys
[]
u
.
Key
for
k
:=
range
ch
{
keys
=
append
(
keys
,
k
)
}
return
keys
,
nil
}
// AllKeysChan runs a query for keys from the blockstore.
// AllKeysChan runs a query for keys from the blockstore.
// this is very simplistic, in the future, take dsq.Query as a param?
// this is very simplistic, in the future, take dsq.Query as a param?
//
//
...
...
blocks/blockstore/blockstore_test.go
浏览文件 @
63c25285
...
@@ -63,14 +63,24 @@ func newBlockStoreWithKeys(t *testing.T, d ds.Datastore, N int) (Blockstore, []u
...
@@ -63,14 +63,24 @@ func newBlockStoreWithKeys(t *testing.T, d ds.Datastore, N int) (Blockstore, []u
return
bs
,
keys
return
bs
,
keys
}
}
func
collect
(
ch
<-
chan
u
.
Key
)
[]
u
.
Key
{
var
keys
[]
u
.
Key
for
k
:=
range
ch
{
keys
=
append
(
keys
,
k
)
}
return
keys
}
func
TestAllKeysSimple
(
t
*
testing
.
T
)
{
func
TestAllKeysSimple
(
t
*
testing
.
T
)
{
bs
,
keys
:=
newBlockStoreWithKeys
(
t
,
nil
,
100
)
bs
,
keys
:=
newBlockStoreWithKeys
(
t
,
nil
,
100
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
keys2
,
err
:=
bs
.
AllKeys
(
ctx
)
ch
,
err
:=
bs
.
AllKeysChan
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
keys2
:=
collect
(
ch
)
// for _, k2 := range keys2 {
// for _, k2 := range keys2 {
// t.Log("found ", k2.Pretty())
// t.Log("found ", k2.Pretty())
// }
// }
...
@@ -90,10 +100,11 @@ func TestAllKeysRespectsContext(t *testing.T) {
...
@@ -90,10 +100,11 @@ func TestAllKeysRespectsContext(t *testing.T) {
getKeys
:=
func
(
ctx
context
.
Context
)
{
getKeys
:=
func
(
ctx
context
.
Context
)
{
started
<-
struct
{}{}
started
<-
struct
{}{}
_
,
err
:=
bs
.
AllKeys
(
ctx
)
// once without cancelling
ch
,
err
:=
bs
.
AllKeysChan
(
ctx
)
// once without cancelling
if
err
!=
nil
{
if
err
!=
nil
{
errors
<-
err
errors
<-
err
}
}
_
=
collect
(
ch
)
done
<-
struct
{}{}
done
<-
struct
{}{}
errors
<-
nil
// a nil one to signal break
errors
<-
nil
// a nil one to signal break
}
}
...
...
blocks/blockstore/write_cache.go
浏览文件 @
63c25285
...
@@ -45,10 +45,6 @@ func (w *writecache) Put(b *blocks.Block) error {
...
@@ -45,10 +45,6 @@ func (w *writecache) Put(b *blocks.Block) error {
return
w
.
blockstore
.
Put
(
b
)
return
w
.
blockstore
.
Put
(
b
)
}
}
func
(
w
*
writecache
)
AllKeys
(
ctx
context
.
Context
)
([]
u
.
Key
,
error
)
{
return
w
.
blockstore
.
AllKeys
(
ctx
)
}
func
(
w
*
writecache
)
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
u
.
Key
,
error
)
{
func
(
w
*
writecache
)
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
u
.
Key
,
error
)
{
return
w
.
blockstore
.
AllKeysChan
(
ctx
)
return
w
.
blockstore
.
AllKeysChan
(
ctx
)
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论