Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
ab9b7363
提交
ab9b7363
authored
8月 25, 2017
作者:
Jeromy Johnson
提交者:
GitHub
8月 25, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4169 from ipfs/fix/4062
add blocks to the blockstore before returning them from blockservice sessions.
上级
9c0f9362
b22d3fbf
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
15 行删除
+17
-15
bitswap.go
exchange/bitswap/bitswap.go
+17
-15
没有找到文件。
exchange/bitswap/bitswap.go
浏览文件 @
ab9b7363
...
@@ -298,6 +298,14 @@ func (bs *Bitswap) CancelWants(cids []*cid.Cid, ses uint64) {
...
@@ -298,6 +298,14 @@ func (bs *Bitswap) CancelWants(cids []*cid.Cid, ses uint64) {
// HasBlock announces the existance of a block to this bitswap service. The
// HasBlock announces the existance of a block to this bitswap service. The
// service will potentially notify its peers.
// service will potentially notify its peers.
func
(
bs
*
Bitswap
)
HasBlock
(
blk
blocks
.
Block
)
error
{
func
(
bs
*
Bitswap
)
HasBlock
(
blk
blocks
.
Block
)
error
{
return
bs
.
receiveBlockFrom
(
blk
,
""
)
}
// TODO: Some of this stuff really only needs to be done when adding a block
// from the user, not when receiving it from the network.
// In case you run `git blame` on this comment, I'll save you some time: ask
// @whyrusleeping, I don't know the answers you seek.
func
(
bs
*
Bitswap
)
receiveBlockFrom
(
blk
blocks
.
Block
,
from
peer
.
ID
)
error
{
select
{
select
{
case
<-
bs
.
process
.
Closing
()
:
case
<-
bs
.
process
.
Closing
()
:
return
errors
.
New
(
"bitswap is closed"
)
return
errors
.
New
(
"bitswap is closed"
)
...
@@ -317,8 +325,11 @@ func (bs *Bitswap) HasBlock(blk blocks.Block) error {
...
@@ -317,8 +325,11 @@ func (bs *Bitswap) HasBlock(blk blocks.Block) error {
// it now as it requires more thought and isnt causing immediate problems.
// it now as it requires more thought and isnt causing immediate problems.
bs
.
notifications
.
Publish
(
blk
)
bs
.
notifications
.
Publish
(
blk
)
for
_
,
s
:=
range
bs
.
SessionsForBlock
(
blk
.
Cid
())
{
k
:=
blk
.
Cid
()
s
.
receiveBlockFrom
(
""
,
blk
)
ks
:=
[]
*
cid
.
Cid
{
k
}
for
_
,
s
:=
range
bs
.
SessionsForBlock
(
k
)
{
s
.
receiveBlockFrom
(
from
,
blk
)
bs
.
CancelWants
(
ks
,
s
.
id
)
}
}
bs
.
engine
.
AddBlock
(
blk
)
bs
.
engine
.
AddBlock
(
blk
)
...
@@ -379,21 +390,12 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
...
@@ -379,21 +390,12 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
bs
.
updateReceiveCounters
(
b
)
bs
.
updateReceiveCounters
(
b
)
k
:=
b
.
Cid
()
log
.
Event
(
ctx
,
"Bitswap.GetBlockRequest.End"
,
k
)
for
_
,
ses
:=
range
bs
.
SessionsForBlock
(
k
)
{
ses
.
receiveBlockFrom
(
p
,
b
)
bs
.
CancelWants
([]
*
cid
.
Cid
{
k
},
ses
.
id
)
}
log
.
Debugf
(
"got block %s from %s"
,
b
,
p
)
log
.
Debugf
(
"got block %s from %s"
,
b
,
p
)
// TODO: rework this to not call 'HasBlock'. 'HasBlock' is really
// designed to be called when blocks are coming in from non-bitswap
if
err
:=
bs
.
receiveBlockFrom
(
b
,
p
);
err
!=
nil
{
// places (like the user manually adding data)
log
.
Warningf
(
"ReceiveMessage recvBlockFrom error: %s"
,
err
)
if
err
:=
bs
.
HasBlock
(
b
);
err
!=
nil
{
log
.
Warningf
(
"ReceiveMessage HasBlock error: %s"
,
err
)
}
}
log
.
Event
(
ctx
,
"Bitswap.GetBlockRequest.End"
,
b
.
Cid
())
}(
block
)
}(
block
)
}
}
wg
.
Wait
()
wg
.
Wait
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论