Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
8830aae9
提交
8830aae9
authored
8月 22, 2016
作者:
Jeromy Johnson
提交者:
GitHub
8月 22, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3091 from ipfs/feat/temp-err-retries
datastore: blockstore should retry when it encounters temp errors
上级
4cffc8db
88130080
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
41 行增加
和
17 行删除
+41
-17
builder.go
core/builder.go
+23
-3
bitswap.go
exchange/bitswap/bitswap.go
+1
-13
bitswap_test.go
exchange/bitswap/bitswap_test.go
+5
-1
package.json
package.json
+12
-0
没有找到文件。
core/builder.go
浏览文件 @
8830aae9
...
...
@@ -4,6 +4,9 @@ import (
"crypto/rand"
"encoding/base64"
"errors"
"os"
"syscall"
"time"
bstore
"github.com/ipfs/go-ipfs/blocks/blockstore"
key
"github.com/ipfs/go-ipfs/blocks/key"
...
...
@@ -14,12 +17,13 @@ import (
pin
"github.com/ipfs/go-ipfs/pin"
repo
"github.com/ipfs/go-ipfs/repo"
cfg
"github.com/ipfs/go-ipfs/repo/config"
ds
"gx/ipfs/QmTxLSvdhwg68WJimdS6icLPhZi28aTp6b7uihC2Yb47Xk/go-datastore"
dsync
"gx/ipfs/QmTxLSvdhwg68WJimdS6icLPhZi28aTp6b7uihC2Yb47Xk/go-datastore/sync"
pstore
"gx/ipfs/QmQdnfvZQuhdT93LNc5bos52wAmdr3G2p6G8teLJMEN32P/go-libp2p-peerstore"
goprocessctx
"gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
ds
"gx/ipfs/QmTxLSvdhwg68WJimdS6icLPhZi28aTp6b7uihC2Yb47Xk/go-datastore"
dsync
"gx/ipfs/QmTxLSvdhwg68WJimdS6icLPhZi28aTp6b7uihC2Yb47Xk/go-datastore/sync"
ci
"gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto"
retry
"gx/ipfs/QmY6UVhgS2ZxhbM5qU23Fnz3daJwfyAuNErd3StmVofnAU/retry-datastore"
context
"gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
)
...
...
@@ -127,14 +131,30 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
return
n
,
nil
}
func
isTooManyFDError
(
err
error
)
bool
{
perr
,
ok
:=
err
.
(
*
os
.
PathError
)
if
ok
&&
perr
.
Err
==
syscall
.
EMFILE
{
return
true
}
return
false
}
func
setupNode
(
ctx
context
.
Context
,
n
*
IpfsNode
,
cfg
*
BuildCfg
)
error
{
// setup local peer ID (private key is loaded in online setup)
if
err
:=
n
.
loadID
();
err
!=
nil
{
return
err
}
rds
:=
&
retry
.
Datastore
{
Batching
:
n
.
Repo
.
Datastore
(),
Delay
:
time
.
Millisecond
*
200
,
Retries
:
6
,
TempErrFunc
:
isTooManyFDError
,
}
var
err
error
bs
:=
bstore
.
NewBlockstore
(
n
.
Repo
.
Datastore
()
)
bs
:=
bstore
.
NewBlockstore
(
rds
)
opts
:=
bstore
.
DefaultCacheOpts
()
conf
,
err
:=
n
.
Repo
.
Config
()
if
err
!=
nil
{
...
...
exchange/bitswap/bitswap.go
浏览文件 @
8830aae9
...
...
@@ -265,7 +265,7 @@ func (bs *Bitswap) HasBlock(blk blocks.Block) error {
default
:
}
err
:=
bs
.
tryPutBlock
(
blk
,
4
)
// attempt to store block up to four times
err
:=
bs
.
blockstore
.
Put
(
blk
)
if
err
!=
nil
{
log
.
Errorf
(
"Error writing block to datastore: %s"
,
err
)
return
err
...
...
@@ -284,18 +284,6 @@ func (bs *Bitswap) HasBlock(blk blocks.Block) error {
return
nil
}
func
(
bs
*
Bitswap
)
tryPutBlock
(
blk
blocks
.
Block
,
attempts
int
)
error
{
var
err
error
for
i
:=
0
;
i
<
attempts
;
i
++
{
if
err
=
bs
.
blockstore
.
Put
(
blk
);
err
==
nil
{
break
}
time
.
Sleep
(
time
.
Millisecond
*
time
.
Duration
(
400
*
(
i
+
1
)))
}
return
err
}
func
(
bs
*
Bitswap
)
ReceiveMessage
(
ctx
context
.
Context
,
p
peer
.
ID
,
incoming
bsmsg
.
BitSwapMessage
)
{
// This call records changes to wantlists, blocks received,
// and number of bytes transfered.
...
...
exchange/bitswap/bitswap_test.go
浏览文件 @
8830aae9
...
...
@@ -24,8 +24,12 @@ import (
// well under varying conditions
const
kNetworkDelay
=
0
*
time
.
Millisecond
func
getVirtualNetwork
()
tn
.
Network
{
return
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
}
func
TestClose
(
t
*
testing
.
T
)
{
vnet
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
)
)
vnet
:=
getVirtualNetwork
(
)
sesgen
:=
NewTestSessionGenerator
(
vnet
)
defer
sesgen
.
Close
()
bgen
:=
blocksutil
.
NewBlockGenerator
()
...
...
package.json
浏览文件 @
8830aae9
...
...
@@ -195,6 +195,18 @@
"hash"
:
"QmaeHSCBd9XjXxmgHEiKkHtLcMCb2eZsPLKT7bHgBfBkqw"
,
"name"
:
"go-is-domain"
,
"version"
:
"1.0.0"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmY6UVhgS2ZxhbM5qU23Fnz3daJwfyAuNErd3StmVofnAU"
,
"name"
:
"retry-datastore"
,
"version"
:
"1.1.0"
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"QmdjfJJFxgqqR9skVZDmgiGrbKomSqxpaw12rjLNim5NYR"
,
"name"
:
"failstore"
,
"version"
:
"1.0.0"
}
],
"gxVersion"
:
"0.4.0"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论