Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
406e74e2
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
406e74e2
编写于
4月 22, 2015
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
whisper: fix a small data race duirng peer connection
上级
70ded4cb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
14 deletion
+12
-14
whisper/peer.go
whisper/peer.go
+2
-6
whisper/whisper.go
whisper/whisper.go
+10
-8
未找到文件。
whisper/peer.go
浏览文件 @
406e74e2
...
@@ -23,18 +23,14 @@ type peer struct {
...
@@ -23,18 +23,14 @@ type peer struct {
// newPeer creates and initializes a new whisper peer connection, returning either
// newPeer creates and initializes a new whisper peer connection, returning either
// the newly constructed link or a failure reason.
// the newly constructed link or a failure reason.
func
newPeer
(
host
*
Whisper
,
remote
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
(
*
peer
,
error
)
{
func
newPeer
(
host
*
Whisper
,
remote
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
*
peer
{
p
:=
&
peer
{
return
&
peer
{
host
:
host
,
host
:
host
,
peer
:
remote
,
peer
:
remote
,
ws
:
rw
,
ws
:
rw
,
known
:
set
.
New
(),
known
:
set
.
New
(),
quit
:
make
(
chan
struct
{}),
quit
:
make
(
chan
struct
{}),
}
}
if
err
:=
p
.
handshake
();
err
!=
nil
{
return
nil
,
err
}
return
p
,
nil
}
}
// start initiates the peer updater, periodically broadcasting the whisper packets
// start initiates the peer updater, periodically broadcasting the whisper packets
...
...
whisper/whisper.go
浏览文件 @
406e74e2
...
@@ -168,15 +168,9 @@ func (self *Whisper) Messages(id int) []*Message {
...
@@ -168,15 +168,9 @@ func (self *Whisper) Messages(id int) []*Message {
// handlePeer is called by the underlying P2P layer when the whisper sub-protocol
// handlePeer is called by the underlying P2P layer when the whisper sub-protocol
// connection is negotiated.
// connection is negotiated.
func
(
self
*
Whisper
)
handlePeer
(
peer
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
error
{
func
(
self
*
Whisper
)
handlePeer
(
peer
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
error
{
// Create, initialize and start the whisper peer
// Create the new peer and start tracking it
whisperPeer
,
err
:=
newPeer
(
self
,
peer
,
rw
)
whisperPeer
:=
newPeer
(
self
,
peer
,
rw
)
if
err
!=
nil
{
return
err
}
whisperPeer
.
start
()
defer
whisperPeer
.
stop
()
// Start tracking the active peer
self
.
peerMu
.
Lock
()
self
.
peerMu
.
Lock
()
self
.
peers
[
whisperPeer
]
=
struct
{}{}
self
.
peers
[
whisperPeer
]
=
struct
{}{}
self
.
peerMu
.
Unlock
()
self
.
peerMu
.
Unlock
()
...
@@ -186,6 +180,14 @@ func (self *Whisper) handlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
...
@@ -186,6 +180,14 @@ func (self *Whisper) handlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
delete
(
self
.
peers
,
whisperPeer
)
delete
(
self
.
peers
,
whisperPeer
)
self
.
peerMu
.
Unlock
()
self
.
peerMu
.
Unlock
()
}()
}()
// Run the peer handshake and state updates
if
err
:=
whisperPeer
.
handshake
();
err
!=
nil
{
return
err
}
whisperPeer
.
start
()
defer
whisperPeer
.
stop
()
// Read and process inbound messages directly to merge into client-global state
// Read and process inbound messages directly to merge into client-global state
for
{
for
{
// Fetch the next packet and decode the contained envelopes
// Fetch the next packet and decode the contained envelopes
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录