Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
786406bd
提交
786406bd
authored
1月 21, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #588 from jbenet/misc/2015-01-16
Miscellaneous changes
上级
f6111d82
bb89e0d8
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
19 行增加
和
37 行删除
+19
-37
bitswap.go
exchange/bitswap/bitswap.go
+10
-28
engine.go
exchange/bitswap/decision/engine.go
+3
-3
config.go
repo/config/config.go
+1
-1
test-lib.sh
test/sharness/lib/test-lib.sh
+1
-1
t0020-init.sh
test/sharness/t0020-init.sh
+2
-2
t0060-daemon.sh
test/sharness/t0060-daemon.sh
+2
-2
没有找到文件。
exchange/bitswap/bitswap.go
浏览文件 @
786406bd
...
...
@@ -108,7 +108,6 @@ type bitswap struct {
// GetBlock attempts to retrieve a particular block from peers within the
// deadline enforced by the context.
func
(
bs
*
bitswap
)
GetBlock
(
parent
context
.
Context
,
k
u
.
Key
)
(
*
blocks
.
Block
,
error
)
{
log
:=
log
.
Prefix
(
"bitswap(%s).GetBlock(%s)"
,
bs
.
self
,
k
)
// Any async work initiated by this function must end when this function
// returns. To ensure this, derive a new context. Note that it is okay to
...
...
@@ -121,11 +120,9 @@ func (bs *bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err
ctx
=
eventlog
.
ContextWithLoggable
(
ctx
,
eventlog
.
Uuid
(
"GetBlockRequest"
))
defer
log
.
EventBegin
(
ctx
,
"GetBlockRequest"
,
&
k
)
.
Done
()
log
.
Debugf
(
"GetBlockRequestBegin"
)
defer
func
()
{
cancelFunc
()
log
.
Debugf
(
"GetBlockRequestEnd"
)
}()
promise
,
err
:=
bs
.
GetBlocks
(
ctx
,
[]
u
.
Key
{
k
})
...
...
@@ -150,7 +147,6 @@ func (bs *bitswap) GetBlock(parent context.Context, k u.Key) (*blocks.Block, err
// resources, provide a context with a reasonably short deadline (ie. not one
// that lasts throughout the lifetime of the server)
func
(
bs
*
bitswap
)
GetBlocks
(
ctx
context
.
Context
,
keys
[]
u
.
Key
)
(
<-
chan
*
blocks
.
Block
,
error
)
{
// TODO log the request
promise
:=
bs
.
notifications
.
Subscribe
(
ctx
,
keys
...
)
select
{
...
...
@@ -172,18 +168,6 @@ func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
return
bs
.
network
.
Provide
(
ctx
,
blk
.
Key
())
}
func
(
bs
*
bitswap
)
sendWantlistMsgToPeer
(
ctx
context
.
Context
,
m
bsmsg
.
BitSwapMessage
,
p
peer
.
ID
)
error
{
log
:=
log
.
Prefix
(
"bitswap(%s).bitswap.sendWantlistMsgToPeer(%d, %s)"
,
bs
.
self
,
len
(
m
.
Wantlist
()),
p
)
log
.
Debug
(
"sending wantlist"
)
if
err
:=
bs
.
send
(
ctx
,
p
,
m
);
err
!=
nil
{
log
.
Errorf
(
"send wantlist error: %s"
,
err
)
return
err
}
log
.
Debugf
(
"send wantlist success"
)
return
nil
}
func
(
bs
*
bitswap
)
sendWantlistMsgToPeers
(
ctx
context
.
Context
,
m
bsmsg
.
BitSwapMessage
,
peers
<-
chan
peer
.
ID
)
error
{
if
peers
==
nil
{
panic
(
"Cant send wantlist to nil peerchan"
)
...
...
@@ -207,7 +191,9 @@ func (bs *bitswap) sendWantlistMsgToPeers(ctx context.Context, m bsmsg.BitSwapMe
wg
.
Add
(
1
)
go
func
(
p
peer
.
ID
)
{
defer
wg
.
Done
()
bs
.
sendWantlistMsgToPeer
(
ctx
,
m
,
p
)
if
err
:=
bs
.
send
(
ctx
,
p
,
m
);
err
!=
nil
{
log
.
Error
(
err
)
// TODO remove if too verbose
}
}(
peerToQuery
)
}
wg
.
Wait
()
...
...
@@ -304,23 +290,19 @@ func (bs *bitswap) clientWorker(parent context.Context) {
case
<-
broadcastSignal
:
// resend unfulfilled wantlist keys
bs
.
sendWantlistToProviders
(
ctx
)
broadcastSignal
=
time
.
After
(
rebroadcastDelay
.
Get
())
case
ks
:=
<-
bs
.
batchRequests
:
if
len
(
ks
)
==
0
{
case
k
ey
s
:=
<-
bs
.
batchRequests
:
if
len
(
k
ey
s
)
==
0
{
log
.
Warning
(
"Received batch request for zero blocks"
)
continue
}
for
i
,
k
:=
range
ks
{
for
i
,
k
:=
range
k
ey
s
{
bs
.
wantlist
.
Add
(
k
,
kMaxPriority
-
i
)
}
// NB: send want list to providers for the first peer in this list.
// the assumption is made that the providers of the first key in
// the set are likely to have others as well.
// This currently holds true in most every situation, since when
// pinning a file, you store and provide all blocks associated with
// it. Later, this assumption may not hold as true if we implement
// newer bitswap strategies.
// NB: Optimization. Assumes that providers of key[0] are likely to
// be able to provide for all keys. This currently holds true in most
// every situation. Later, this assumption may not hold as true.
child
,
_
:=
context
.
WithTimeout
(
ctx
,
providerRequestTimeout
)
providers
:=
bs
.
network
.
FindProvidersAsync
(
child
,
ks
[
0
],
maxProvidersPerRequest
)
providers
:=
bs
.
network
.
FindProvidersAsync
(
child
,
k
ey
s
[
0
],
maxProvidersPerRequest
)
err
:=
bs
.
sendWantlistToPeers
(
ctx
,
providers
)
if
err
!=
nil
{
log
.
Errorf
(
"error sending wantlist: %s"
,
err
)
...
...
exchange/bitswap/decision/engine.go
浏览文件 @
786406bd
...
...
@@ -160,6 +160,9 @@ func (e *Engine) Peers() []peer.ID {
// MessageReceived performs book-keeping. Returns error if passed invalid
// arguments.
func
(
e
*
Engine
)
MessageReceived
(
p
peer
.
ID
,
m
bsmsg
.
BitSwapMessage
)
error
{
e
.
lock
.
Lock
()
defer
e
.
lock
.
Unlock
()
log
:=
log
.
Prefix
(
"bitswap.Engine.MessageReceived(%s)"
,
p
)
log
.
Debugf
(
"enter. %d entries %d blocks"
,
len
(
m
.
Wantlist
()),
len
(
m
.
Blocks
()))
defer
log
.
Debugf
(
"exit"
)
...
...
@@ -175,9 +178,6 @@ func (e *Engine) MessageReceived(p peer.ID, m bsmsg.BitSwapMessage) error {
}
}()
e
.
lock
.
Lock
()
defer
e
.
lock
.
Unlock
()
l
:=
e
.
findOrCreate
(
p
)
if
m
.
Full
()
{
l
.
wantList
=
wl
.
New
()
...
...
repo/config/config.go
浏览文件 @
786406bd
...
...
@@ -32,7 +32,7 @@ const (
// DefaultConfigFile is the filename of the configuration file
DefaultConfigFile
=
"config"
// EnvDir is the environment variable used to change the path root.
EnvDir
=
"IPFS_
DIR
"
EnvDir
=
"IPFS_
PATH
"
)
// PathRoot returns the default configuration root directory
...
...
test/sharness/lib/test-lib.sh
浏览文件 @
786406bd
...
...
@@ -67,7 +67,7 @@ test_wait_output_n_lines_60_sec() {
test_init_ipfs
()
{
test_expect_success
"ipfs init succeeds"
'
export IPFS_
DIR
="$(pwd)/.go-ipfs" &&
export IPFS_
PATH
="$(pwd)/.go-ipfs" &&
ipfs init -b=1024 > /dev/null
'
...
...
test/sharness/t0020-init.sh
浏览文件 @
786406bd
...
...
@@ -9,7 +9,7 @@ test_description="Test init command"
.
lib/test-lib.sh
test_expect_success
"ipfs init succeeds"
'
export IPFS_
DIR
="$(pwd)/.go-ipfs" &&
export IPFS_
PATH
="$(pwd)/.go-ipfs" &&
ipfs init >actual_init
'
...
...
@@ -35,7 +35,7 @@ test_expect_success "ipfs peer id looks good" '
test_expect_success
"ipfs init output looks good"
'
STARTHASH="QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB" &&
echo "initializing ipfs node at $IPFS_
DIR
" >expected &&
echo "initializing ipfs node at $IPFS_
PATH
" >expected &&
echo "generating key pair...done" >>expected &&
echo "peer identity: $PEERID" >>expected &&
printf "\\n%s\\n" "to get started, enter: ipfs cat $STARTHASH" >>expected &&
...
...
test/sharness/t0060-daemon.sh
浏览文件 @
786406bd
...
...
@@ -13,7 +13,7 @@ test_description="Test daemon command"
# NOTE: this should remove bootstrap peers (needs a flag)
test_expect_success
"ipfs daemon --init launches"
'
export IPFS_
DIR
="$(pwd)/.go-ipfs" &&
export IPFS_
PATH
="$(pwd)/.go-ipfs" &&
ipfs daemon --init 2>&1 >actual_init &
'
...
...
@@ -35,7 +35,7 @@ test_expect_success "ipfs peer id looks good" '
# note this is almost the same as t0020-init.sh "ipfs init output looks good"
test_expect_success
"ipfs daemon output looks good"
'
STARTHASH="QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB" &&
echo "initializing ipfs node at $IPFS_
DIR
" >expected &&
echo "initializing ipfs node at $IPFS_
PATH
" >expected &&
echo "generating key pair...done" >>expected &&
echo "peer identity: $PEERID" >>expected &&
echo "\nto get started, enter: ipfs cat $STARTHASH" >>expected &&
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论