Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
ab824a51
提交
ab824a51
authored
1月 12, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added debug printing to peerstream
上级
a768e841
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
69 行增加
和
1 行删除
+69
-1
Godeps.json
Godeps/Godeps.json
+1
-1
conn.go
...ps/_workspace/src/github.com/jbenet/go-peerstream/conn.go
+10
-0
listener.go
...workspace/src/github.com/jbenet/go-peerstream/listener.go
+6
-0
stream.go
.../_workspace/src/github.com/jbenet/go-peerstream/stream.go
+8
-0
swarm.go
...s/_workspace/src/github.com/jbenet/go-peerstream/swarm.go
+44
-0
没有找到文件。
Godeps/Godeps.json
浏览文件 @
ab824a51
...
...
@@ -144,7 +144,7 @@
},
{
"ImportPath"
:
"github.com/jbenet/go-peerstream"
,
"Rev"
:
"c
ddf450fca891e45aa471d882dae2c28ac642fb4
"
"Rev"
:
"c
cc044c2a5999f36743881ff73568660a581f2f2
"
},
{
"ImportPath"
:
"github.com/jbenet/go-random"
,
...
...
Godeps/_workspace/src/github.com/jbenet/go-peerstream/conn.go
浏览文件 @
ab824a51
...
...
@@ -2,6 +2,7 @@ package peerstream
import
(
"errors"
"fmt"
"net"
"sync"
...
...
@@ -55,6 +56,15 @@ func newConn(nconn net.Conn, tconn pst.Conn, s *Swarm) *Conn {
}
}
// String returns a string representation of the Conn
func
(
c
*
Conn
)
String
()
string
{
c
.
streamLock
.
RLock
()
ls
:=
len
(
c
.
streams
)
c
.
streamLock
.
RUnlock
()
f
:=
"<peerstream.Conn %d streams %s <--> %s>"
return
fmt
.
Sprintf
(
f
,
ls
,
c
.
netConn
.
LocalAddr
(),
c
.
netConn
.
RemoteAddr
())
}
// Swarm returns the Swarm associated with this Conn
func
(
c
*
Conn
)
Swarm
()
*
Swarm
{
return
c
.
swarm
...
...
Godeps/_workspace/src/github.com/jbenet/go-peerstream/listener.go
浏览文件 @
ab824a51
...
...
@@ -24,6 +24,12 @@ func newListener(nl net.Listener, s *Swarm) *Listener {
}
}
// String returns a string representation of the Listener
func
(
l
*
Listener
)
String
()
string
{
f
:=
"<peerstream.Listener %s>"
return
fmt
.
Sprintf
(
f
,
l
.
netList
.
Addr
())
}
// NetListener is the underlying net.Listener
func
(
l
*
Listener
)
NetListener
()
net
.
Listener
{
return
l
.
netList
...
...
Godeps/_workspace/src/github.com/jbenet/go-peerstream/stream.go
浏览文件 @
ab824a51
package
peerstream
import
(
"fmt"
pst
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport"
)
...
...
@@ -31,6 +33,12 @@ func newStream(ss pst.Stream, c *Conn) *Stream {
return
s
}
// String returns a string representation of the Stream
func
(
s
*
Stream
)
String
()
string
{
f
:=
"<peerstream.Stream %s <--> %s>"
return
fmt
.
Sprintf
(
f
,
s
.
conn
.
NetConn
()
.
LocalAddr
(),
s
.
conn
.
NetConn
()
.
RemoteAddr
())
}
// SPDYStream returns the underlying *spdystream.Stream
func
(
s
*
Stream
)
Stream
()
pst
.
Stream
{
return
s
.
pstStream
...
...
Godeps/_workspace/src/github.com/jbenet/go-peerstream/swarm.go
浏览文件 @
ab824a51
...
...
@@ -2,6 +2,7 @@ package peerstream
import
(
"errors"
"fmt"
"net"
"sync"
"time"
...
...
@@ -56,6 +57,49 @@ func NewSwarm(t pst.Transport) *Swarm {
return
s
}
// String returns a string with various internal stats
func
(
s
*
Swarm
)
String
()
string
{
s
.
listenerLock
.
Lock
()
ls
:=
len
(
s
.
listeners
)
s
.
listenerLock
.
Unlock
()
s
.
connLock
.
Lock
()
cs
:=
len
(
s
.
conns
)
s
.
connLock
.
Unlock
()
s
.
streamLock
.
Lock
()
ss
:=
len
(
s
.
streams
)
s
.
streamLock
.
Unlock
()
str
:=
"<peerstream.Swarm %d listeners %d conns %d streams>"
return
fmt
.
Sprintf
(
str
,
ls
,
cs
,
ss
)
}
// Dump returns a string with all the internal state
func
(
s
*
Swarm
)
Dump
()
string
{
str
:=
s
.
String
()
+
"
\n
"
s
.
listenerLock
.
Lock
()
for
l
,
_
:=
range
s
.
listeners
{
str
+=
fmt
.
Sprintf
(
"
\t
%s %v
\n
"
,
l
,
l
.
Groups
())
}
s
.
listenerLock
.
Unlock
()
s
.
connLock
.
Lock
()
for
c
,
_
:=
range
s
.
conns
{
str
+=
fmt
.
Sprintf
(
"
\t
%s %v
\n
"
,
c
,
c
.
Groups
())
}
s
.
connLock
.
Unlock
()
s
.
streamLock
.
Lock
()
for
ss
,
_
:=
range
s
.
streams
{
str
+=
fmt
.
Sprintf
(
"
\t
%s %v
\n
"
,
ss
,
ss
.
Groups
())
}
s
.
streamLock
.
Unlock
()
return
str
}
// SetStreamHandler assigns the stream handler in the swarm.
// The handler assumes responsibility for closing the stream.
// This need not happen at the end of the handler, leaving the
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论