Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7fcafb66
提交
7fcafb66
authored
3月 15, 2019
作者:
Erik Ingenito
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Gofmt
License: MIT Signed-off-by:
Erik Ingenito
<
erik@carbonfive.com
>
上级
1595253b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
26 行增加
和
30 行删除
+26
-30
provider.go
provider/provider.go
+1
-1
provider_test.go
provider/provider_test.go
+10
-11
queue.go
provider/queue.go
+14
-17
queue_test.go
provider/queue_test.go
+1
-1
没有找到文件。
provider/provider.go
浏览文件 @
7fcafb66
...
...
@@ -11,7 +11,7 @@ import (
routing
"github.com/libp2p/go-libp2p-routing"
)
var
log
=
logging
.
Logger
(
"provider"
)
var
log
=
logging
.
Logger
(
"provider"
)
const
provideOutgoingWorkerLimit
=
8
...
...
provider/provider_test.go
浏览文件 @
7fcafb66
...
...
@@ -6,11 +6,11 @@ import (
"testing"
"time"
blocksutil
"github.com/ipfs/go-ipfs-blocksutil"
cid
"github.com/ipfs/go-cid"
datastore
"github.com/ipfs/go-datastore"
pstore
"github.com/libp2p/go-libp2p-peerstore"
sync
"github.com/ipfs/go-datastore/sync"
blocksutil
"github.com/ipfs/go-ipfs-blocksutil"
pstore
"github.com/libp2p/go-libp2p-peerstore"
)
var
blockGenerator
=
blocksutil
.
NewBlockGenerator
()
...
...
@@ -58,13 +58,13 @@ func TestAnnouncement(t *testing.T) {
for
cids
.
Len
()
>
0
{
select
{
case
cp
:=
<-
r
.
provided
:
if
!
cids
.
Has
(
cp
)
{
t
.
Fatal
(
"Wrong CID provided"
)
}
cids
.
Remove
(
cp
)
case
<-
time
.
After
(
time
.
Second
*
5
)
:
t
.
Fatal
(
"Timeout waiting for cids to be provided."
)
case
cp
:=
<-
r
.
provided
:
if
!
cids
.
Has
(
cp
)
{
t
.
Fatal
(
"Wrong CID provided"
)
}
cids
.
Remove
(
cp
)
case
<-
time
.
After
(
time
.
Second
*
5
)
:
t
.
Fatal
(
"Timeout waiting for cids to be provided."
)
}
}
}
...
...
@@ -77,4 +77,4 @@ func (r *mockRouting) Provide(ctx context.Context, cid cid.Cid, recursive bool)
// Search for peers who are able to provide a given key
func
(
r
*
mockRouting
)
FindProvidersAsync
(
ctx
context
.
Context
,
cid
cid
.
Cid
,
timeout
int
)
<-
chan
pstore
.
PeerInfo
{
return
nil
}
\ No newline at end of file
}
provider/queue.go
浏览文件 @
7fcafb66
...
...
@@ -19,14 +19,11 @@ import (
type
Queue
struct
{
// used to differentiate queues in datastore
// e.g. provider vs reprovider
name
string
ctx
context
.
Context
tail
uint64
head
uint64
ds
datastore
.
Datastore
// Must be threadsafe
name
string
ctx
context
.
Context
tail
uint64
head
uint64
ds
datastore
.
Datastore
// Must be threadsafe
dequeue
chan
cid
.
Cid
enqueue
chan
cid
.
Cid
}
...
...
@@ -39,13 +36,13 @@ func NewQueue(ctx context.Context, name string, ds datastore.Datastore) (*Queue,
return
nil
,
err
}
q
:=
&
Queue
{
name
:
name
,
ctx
:
ctx
,
head
:
head
,
tail
:
tail
,
ds
:
namespaced
,
dequeue
:
make
(
chan
cid
.
Cid
),
enqueue
:
make
(
chan
cid
.
Cid
),
name
:
name
,
ctx
:
ctx
,
head
:
head
,
tail
:
tail
,
ds
:
namespaced
,
dequeue
:
make
(
chan
cid
.
Cid
),
enqueue
:
make
(
chan
cid
.
Cid
),
}
q
.
work
()
return
q
,
nil
...
...
@@ -54,8 +51,8 @@ func NewQueue(ctx context.Context, name string, ds datastore.Datastore) (*Queue,
// Enqueue puts a cid in the queue
func
(
q
*
Queue
)
Enqueue
(
cid
cid
.
Cid
)
{
select
{
case
q
.
enqueue
<-
cid
:
case
<-
q
.
ctx
.
Done
()
:
case
q
.
enqueue
<-
cid
:
case
<-
q
.
ctx
.
Done
()
:
}
}
...
...
provider/queue_test.go
浏览文件 @
7fcafb66
...
...
@@ -22,7 +22,7 @@ func makeCids(n int) []cid.Cid {
func
assertOrdered
(
cids
[]
cid
.
Cid
,
q
*
Queue
,
t
*
testing
.
T
)
{
for
_
,
c
:=
range
cids
{
select
{
case
dequeued
:=
<-
q
.
dequeue
:
case
dequeued
:=
<-
q
.
dequeue
:
if
c
!=
dequeued
{
t
.
Fatalf
(
"Error in ordering of CIDs retrieved from queue. Expected: %s, got: %s"
,
c
,
dequeued
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论