Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
1d5b9036
提交
1d5b9036
authored
3月 07, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added cancel func calls previously ignored
上级
dfe2b167
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
27 行增加
和
13 行删除
+27
-13
ping.go
core/commands/ping.go
+4
-2
net.go
core/corenet/net.go
+2
-1
diag.go
diagnostics/diag.go
+3
-2
bitswap.go
exchange/bitswap/bitswap.go
+4
-2
merkledag.go
merkledag/merkledag.go
+2
-1
publisher.go
namesys/publisher.go
+3
-1
swarm_dial.go
p2p/net/swarm/swarm_dial.go
+2
-1
pin.go
pin/pin.go
+3
-1
dht.go
routing/dht/dht.go
+2
-1
reader.go
unixfs/tar/reader.go
+2
-1
没有找到文件。
core/commands/ping.go
浏览文件 @
1d5b9036
...
...
@@ -126,7 +126,8 @@ func pingPeer(ctx context.Context, n *core.IpfsNode, pid peer.ID, numPings int)
Text
:
fmt
.
Sprintf
(
"Looking up peer %s"
,
pid
.
Pretty
()),
}
ctx
,
_
:=
context
.
WithTimeout
(
ctx
,
kPingTimeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
kPingTimeout
)
defer
cancel
()
p
,
err
:=
n
.
Routing
.
FindPeer
(
ctx
,
pid
)
if
err
!=
nil
{
outChan
<-
&
PingResult
{
Text
:
fmt
.
Sprintf
(
"Peer lookup error: %s"
,
err
)}
...
...
@@ -147,7 +148,8 @@ func pingPeer(ctx context.Context, n *core.IpfsNode, pid peer.ID, numPings int)
default
:
}
ctx
,
_
:=
context
.
WithTimeout
(
ctx
,
kPingTimeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
kPingTimeout
)
defer
cancel
()
took
,
err
:=
n
.
Routing
.
Ping
(
ctx
,
pid
)
if
err
!=
nil
{
log
.
Debugf
(
"Ping error: %s"
,
err
)
...
...
core/corenet/net.go
浏览文件 @
1d5b9036
...
...
@@ -54,7 +54,8 @@ func Listen(nd *core.IpfsNode, protocol string) (*ipfsListener, error) {
}
func
Dial
(
nd
*
core
.
IpfsNode
,
p
peer
.
ID
,
protocol
string
)
(
net
.
Stream
,
error
)
{
ctx
,
_
:=
context
.
WithTimeout
(
nd
.
Context
(),
time
.
Second
*
30
)
ctx
,
cancel
:=
context
.
WithTimeout
(
nd
.
Context
(),
time
.
Second
*
30
)
defer
cancel
()
err
:=
nd
.
PeerHost
.
Connect
(
ctx
,
peer
.
PeerInfo
{
ID
:
p
})
if
err
!=
nil
{
return
nil
,
err
...
...
diagnostics/diag.go
浏览文件 @
1d5b9036
...
...
@@ -14,12 +14,12 @@ import (
ggio
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/io"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
ctxutil
"github.com/jbenet/go-ipfs/util/ctx"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
host
"github.com/jbenet/go-ipfs/p2p/host"
inet
"github.com/jbenet/go-ipfs/p2p/net"
peer
"github.com/jbenet/go-ipfs/p2p/peer"
protocol
"github.com/jbenet/go-ipfs/p2p/protocol"
ctxutil
"github.com/jbenet/go-ipfs/util/ctx"
pb
"github.com/jbenet/go-ipfs/diagnostics/internal/pb"
util
"github.com/jbenet/go-ipfs/util"
...
...
@@ -138,7 +138,8 @@ func newID() string {
// GetDiagnostic runs a diagnostics request across the entire network
func
(
d
*
Diagnostics
)
GetDiagnostic
(
timeout
time
.
Duration
)
([]
*
DiagInfo
,
error
)
{
log
.
Debug
(
"Getting diagnostic."
)
ctx
,
_
:=
context
.
WithTimeout
(
context
.
TODO
(),
timeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
timeout
)
defer
cancel
()
diagID
:=
newID
()
d
.
diagLock
.
Lock
()
...
...
exchange/bitswap/bitswap.go
浏览文件 @
1d5b9036
...
...
@@ -269,7 +269,8 @@ func (bs *Bitswap) sendWantlistToProviders(ctx context.Context, entries []wantli
go
func
(
k
u
.
Key
)
{
defer
wg
.
Done
()
child
,
_
:=
context
.
WithTimeout
(
ctx
,
providerRequestTimeout
)
child
,
cancel
:=
context
.
WithTimeout
(
ctx
,
providerRequestTimeout
)
defer
cancel
()
providers
:=
bs
.
network
.
FindProvidersAsync
(
child
,
k
,
maxProvidersPerRequest
)
for
prov
:=
range
providers
{
sendToPeers
<-
prov
...
...
@@ -311,10 +312,11 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
// Should only track *useful* messages in ledger
for
_
,
block
:=
range
incoming
.
Blocks
()
{
hasBlockCtx
,
_
:=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
hasBlockCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
if
err
:=
bs
.
HasBlock
(
hasBlockCtx
,
block
);
err
!=
nil
{
log
.
Debug
(
err
)
}
cancel
()
}
var
keys
[]
u
.
Key
...
...
merkledag/merkledag.go
浏览文件 @
1d5b9036
...
...
@@ -88,7 +88,8 @@ func (n *dagService) Get(k u.Key) (*Node, error) {
return
nil
,
fmt
.
Errorf
(
"dagService is nil"
)
}
ctx
,
_
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Minute
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Minute
)
defer
cancel
()
// we shouldn't use an arbitrary timeout here.
// since Get doesnt take in a context yet, we give a large upper bound.
// think of an http request. we want it to go on as long as the client requests it.
...
...
namesys/publisher.go
浏览文件 @
1d5b9036
...
...
@@ -60,9 +60,11 @@ func (p *ipnsPublisher) Publish(ctx context.Context, k ci.PrivKey, value u.Key)
nameb
:=
u
.
Hash
(
pkbytes
)
namekey
:=
u
.
Key
(
"/pk/"
+
string
(
nameb
))
timectx
,
cancel
:=
context
.
WithDeadline
(
ctx
,
time
.
Now
()
.
Add
(
time
.
Second
*
10
))
defer
cancel
()
log
.
Debugf
(
"Storing pubkey at: %s"
,
namekey
)
// Store associated public key
timectx
,
_
:=
context
.
WithDeadline
(
ctx
,
time
.
Now
()
.
Add
(
time
.
Second
*
10
))
err
=
p
.
routing
.
PutValue
(
timectx
,
namekey
,
pkbytes
)
if
err
!=
nil
{
return
err
...
...
p2p/net/swarm/swarm_dial.go
浏览文件 @
1d5b9036
...
...
@@ -227,8 +227,9 @@ func (s *Swarm) gatedDialAttempt(ctx context.Context, p peer.ID) (*Conn, error)
// if it succeeds, dial will add the conn to the swarm itself.
defer
log
.
EventBegin
(
ctx
,
"swarmDialAttemptStart"
,
logdial
)
.
Done
()
ctxT
,
_
:=
context
.
WithTimeout
(
ctx
,
s
.
dialT
)
ctxT
,
cancel
:=
context
.
WithTimeout
(
ctx
,
s
.
dialT
)
conn
,
err
:=
s
.
dial
(
ctxT
,
p
)
cancel
()
s
.
dsync
.
Unlock
(
p
)
log
.
Debugf
(
"dial end %s"
,
conn
)
if
err
!=
nil
{
...
...
pin/pin.go
浏览文件 @
1d5b9036
...
...
@@ -172,7 +172,9 @@ func (p *pinner) pinIndirectRecurse(node *mdag.Node) error {
}
func
(
p
*
pinner
)
pinLinks
(
node
*
mdag
.
Node
)
error
{
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
60
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
60
)
defer
cancel
()
for
_
,
ng
:=
range
p
.
dserv
.
GetDAG
(
ctx
,
node
)
{
subnode
,
err
:=
ng
.
Get
()
if
err
!=
nil
{
...
...
routing/dht/dht.go
浏览文件 @
1d5b9036
...
...
@@ -357,11 +357,12 @@ func (dht *IpfsDHT) PingRoutine(t time.Duration) {
rand
.
Read
(
id
)
peers
:=
dht
.
routingTable
.
NearestPeers
(
kb
.
ConvertKey
(
u
.
Key
(
id
)),
5
)
for
_
,
p
:=
range
peers
{
ctx
,
_
:=
context
.
WithTimeout
(
dht
.
Context
(),
time
.
Second
*
5
)
ctx
,
cancel
:=
context
.
WithTimeout
(
dht
.
Context
(),
time
.
Second
*
5
)
_
,
err
:=
dht
.
Ping
(
ctx
,
p
)
if
err
!=
nil
{
log
.
Debugf
(
"Ping error: %s"
,
err
)
}
cancel
()
}
case
<-
dht
.
Closing
()
:
return
...
...
unixfs/tar/reader.go
浏览文件 @
1d5b9036
...
...
@@ -86,7 +86,8 @@ func (r *Reader) writeToBuf(dagnode *mdag.Node, path string, depth int) {
}
r
.
flush
()
ctx
,
_
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Second
*
60
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Second
*
60
)
defer
cancel
()
for
i
,
ng
:=
range
r
.
dag
.
GetDAG
(
ctx
,
dagnode
)
{
childNode
,
err
:=
ng
.
Get
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论