Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
e6498b37
提交
e6498b37
authored
9月 05, 2014
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix issue with blocks not being trimmed properly and being too large to be sent over the network
上级
f5295885
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
14 行增加
和
3 行删除
+14
-3
bitswap.go
bitswap/bitswap.go
+3
-1
core.go
core/core.go
+1
-0
splitting.go
importer/splitting.go
+1
-1
conn.go
swarm/conn.go
+4
-1
swarm.go
swarm/swarm.go
+5
-0
没有找到文件。
bitswap/bitswap.go
浏览文件 @
e6498b37
...
@@ -220,6 +220,8 @@ func (bs *BitSwap) peerWantsBlock(p *peer.Peer, want string) {
...
@@ -220,6 +220,8 @@ func (bs *BitSwap) peerWantsBlock(p *peer.Peer, want string) {
}
}
bs
.
SendBlock
(
p
,
bblk
)
bs
.
SendBlock
(
p
,
bblk
)
ledg
.
SentBytes
(
len
(
blk
))
ledg
.
SentBytes
(
len
(
blk
))
}
else
{
u
.
DOut
(
"Decided not to send block."
)
}
}
}
}
...
@@ -248,7 +250,7 @@ func (bs *BitSwap) GetLedger(p *peer.Peer) *Ledger {
...
@@ -248,7 +250,7 @@ func (bs *BitSwap) GetLedger(p *peer.Peer) *Ledger {
}
}
l
=
new
(
Ledger
)
l
=
new
(
Ledger
)
l
.
Strategy
=
StandardS
trategy
l
.
Strategy
=
bs
.
s
trategy
l
.
Partner
=
p
l
.
Partner
=
p
bs
.
partners
[
p
.
Key
()]
=
l
bs
.
partners
[
p
.
Key
()]
=
l
return
l
return
l
...
...
core/core.go
浏览文件 @
e6498b37
...
@@ -75,6 +75,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
...
@@ -75,6 +75,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
swap
.
SetStrategy
(
bitswap
.
YesManStrategy
)
}
}
bs
,
err
:=
bserv
.
NewBlockService
(
d
,
swap
)
bs
,
err
:=
bserv
.
NewBlockService
(
d
,
swap
)
...
...
importer/splitting.go
浏览文件 @
e6498b37
...
@@ -24,7 +24,7 @@ func SplitterBySize(n int) BlockSplitter {
...
@@ -24,7 +24,7 @@ func SplitterBySize(n int) BlockSplitter {
return
return
}
}
if
nread
<
n
{
if
nread
<
n
{
chunk
=
chunk
[
:
n
]
chunk
=
chunk
[
:
n
read
]
}
}
out
<-
chunk
out
<-
chunk
}
}
...
...
swarm/conn.go
浏览文件 @
e6498b37
...
@@ -13,6 +13,8 @@ import (
...
@@ -13,6 +13,8 @@ import (
// ChanBuffer is the size of the buffer in the Conn Chan
// ChanBuffer is the size of the buffer in the Conn Chan
const
ChanBuffer
=
10
const
ChanBuffer
=
10
const
MaxMessageSize
=
1
<<
19
// Conn represents a connection to another Peer (IPFS Node).
// Conn represents a connection to another Peer (IPFS Node).
type
Conn
struct
{
type
Conn
struct
{
Peer
*
peer
.
Peer
Peer
*
peer
.
Peer
...
@@ -66,13 +68,14 @@ func newConnChans(c *Conn) error {
...
@@ -66,13 +68,14 @@ func newConnChans(c *Conn) error {
c
.
Closed
=
make
(
chan
bool
,
1
)
c
.
Closed
=
make
(
chan
bool
,
1
)
go
c
.
Outgoing
.
WriteTo
(
c
.
Conn
)
go
c
.
Outgoing
.
WriteTo
(
c
.
Conn
)
go
c
.
Incoming
.
ReadFrom
(
c
.
Conn
,
1
<<
12
)
go
c
.
Incoming
.
ReadFrom
(
c
.
Conn
,
MaxMessageSize
)
return
nil
return
nil
}
}
// Close closes the connection, and associated channels.
// Close closes the connection, and associated channels.
func
(
s
*
Conn
)
Close
()
error
{
func
(
s
*
Conn
)
Close
()
error
{
u
.
DOut
(
"Closing Conn.
\n
"
)
if
s
.
Conn
==
nil
{
if
s
.
Conn
==
nil
{
return
fmt
.
Errorf
(
"Already closed"
)
// already closed
return
fmt
.
Errorf
(
"Already closed"
)
// already closed
}
}
...
...
swarm/swarm.go
浏览文件 @
e6498b37
...
@@ -279,6 +279,10 @@ func (s *Swarm) fanOut() {
...
@@ -279,6 +279,10 @@ func (s *Swarm) fanOut() {
return
return
}
}
if
len
(
msg
.
Data
)
>
MaxMessageSize
{
s
.
Error
(
fmt
.
Errorf
(
"Exceeded max message size! (tried to send len = %d)"
,
len
(
msg
.
Data
)))
}
s
.
connsLock
.
RLock
()
s
.
connsLock
.
RLock
()
conn
,
found
:=
s
.
conns
[
msg
.
Peer
.
Key
()]
conn
,
found
:=
s
.
conns
[
msg
.
Peer
.
Key
()]
s
.
connsLock
.
RUnlock
()
s
.
connsLock
.
RUnlock
()
...
@@ -459,6 +463,7 @@ func (s *Swarm) ConnectNew(addr *ma.Multiaddr) (*peer.Peer, error) {
...
@@ -459,6 +463,7 @@ func (s *Swarm) ConnectNew(addr *ma.Multiaddr) (*peer.Peer, error) {
// Removes a given peer from the swarm and closes connections to it
// Removes a given peer from the swarm and closes connections to it
func
(
s
*
Swarm
)
Drop
(
p
*
peer
.
Peer
)
error
{
func
(
s
*
Swarm
)
Drop
(
p
*
peer
.
Peer
)
error
{
u
.
DOut
(
"Dropping peer: [%s]
\n
"
,
p
.
ID
.
Pretty
())
s
.
connsLock
.
RLock
()
s
.
connsLock
.
RLock
()
conn
,
found
:=
s
.
conns
[
u
.
Key
(
p
.
ID
)]
conn
,
found
:=
s
.
conns
[
u
.
Key
(
p
.
ID
)]
s
.
connsLock
.
RUnlock
()
s
.
connsLock
.
RUnlock
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论