Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
e93c0c09
提交
e93c0c09
authored
9月 05, 2015
作者:
Juan Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1653 from ipfs/async-cmd-error
allow channel marshaler to return errors from cmds.Response
上级
93e9f841
4d8eddce
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
23 行增加
和
2 行删除
+23
-2
blockservice.go
blockservice/blockservice.go
+8
-2
channelmarshaler.go
commands/channelmarshaler.go
+5
-0
response.go
commands/response.go
+1
-0
dht.go
core/commands/dht.go
+5
-0
ping.go
core/commands/ping.go
+1
-0
refs.go
core/commands/refs.go
+1
-0
repo.go
core/commands/repo.go
+1
-0
stat.go
core/commands/stat.go
+1
-0
没有找到文件。
blockservice/blockservice.go
浏览文件 @
e93c0c09
...
...
@@ -96,19 +96,25 @@ func (s *BlockService) GetBlock(ctx context.Context, k key.Key) (*blocks.Block,
block
,
err
:=
s
.
Blockstore
.
Get
(
k
)
if
err
==
nil
{
return
block
,
nil
}
if
err
==
blockstore
.
ErrNotFound
&&
s
.
Exchange
!=
nil
{
// TODO be careful checking ErrNotFound. If the underlying
// implementation changes, this will break.
}
else
if
err
==
blockstore
.
ErrNotFound
&&
s
.
Exchange
!=
nil
{
log
.
Debug
(
"Blockservice: Searching bitswap."
)
blk
,
err
:=
s
.
Exchange
.
GetBlock
(
ctx
,
k
)
if
err
!=
nil
{
return
nil
,
err
}
return
blk
,
nil
}
else
{
}
log
.
Debug
(
"Blockservice GetBlock: Not found."
)
if
err
==
blockstore
.
ErrNotFound
{
return
nil
,
ErrNotFound
}
return
nil
,
err
}
// GetBlocks gets a list of blocks asynchronously and returns through
...
...
commands/channelmarshaler.go
浏览文件 @
e93c0c09
...
...
@@ -5,6 +5,7 @@ import "io"
type
ChannelMarshaler
struct
{
Channel
<-
chan
interface
{}
Marshaler
func
(
interface
{})
(
io
.
Reader
,
error
)
Res
Response
reader
io
.
Reader
}
...
...
@@ -13,6 +14,10 @@ func (cr *ChannelMarshaler) Read(p []byte) (int, error) {
if
cr
.
reader
==
nil
{
val
,
more
:=
<-
cr
.
Channel
if
!
more
{
//check error in response
if
cr
.
Res
.
Error
()
!=
nil
{
return
0
,
cr
.
Res
.
Error
()
}
return
0
,
io
.
EOF
}
...
...
commands/response.go
浏览文件 @
e93c0c09
...
...
@@ -57,6 +57,7 @@ var marshallers = map[EncodingType]Marshaler{
return
&
ChannelMarshaler
{
Channel
:
ch
,
Marshaler
:
marshalJson
,
Res
:
res
,
},
nil
}
...
...
core/commands/dht.go
浏览文件 @
e93c0c09
...
...
@@ -131,6 +131,7 @@ var queryDhtCmd = &cmds.Command{
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -249,6 +250,7 @@ FindProviders will return a list of peers who are able to provide the value requ
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -354,6 +356,7 @@ var findPeerDhtCmd = &cmds.Command{
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -461,6 +464,7 @@ GetValue will return the value stored in the dht at the given key.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -571,6 +575,7 @@ PutValue will store the given key value pair in the dht.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
core/commands/ping.go
浏览文件 @
e93c0c09
...
...
@@ -71,6 +71,7 @@ trip latency information.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
core/commands/refs.go
浏览文件 @
e93c0c09
...
...
@@ -141,6 +141,7 @@ Note: list all refs recursively with -r.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
core/commands/repo.go
浏览文件 @
e93c0c09
...
...
@@ -90,6 +90,7 @@ order to reclaim hard disk space.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
core/commands/stat.go
浏览文件 @
e93c0c09
...
...
@@ -167,6 +167,7 @@ var statBwCmd = &cmds.Command{
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outCh
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论