Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
f382221b
Commit
f382221b
authored
May 30, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Broadcast "peerList" event upon removing or adding peers
parent
6c91ffcf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
ethereum.go
ethereum.go
+19
-3
peer.go
peer.go
+1
-8
No files found.
ethereum.go
View file @
f382221b
...
@@ -165,6 +165,8 @@ func (s *Ethereum) AddPeer(conn net.Conn) {
...
@@ -165,6 +165,8 @@ func (s *Ethereum) AddPeer(conn net.Conn) {
ethutil
.
Config
.
Log
.
Debugf
(
"[SERV] Max connected peers reached. Not adding incoming peer."
)
ethutil
.
Config
.
Log
.
Debugf
(
"[SERV] Max connected peers reached. Not adding incoming peer."
)
}
}
}
}
s
.
reactor
.
Post
(
"peerList"
,
s
.
peers
)
}
}
func
(
s
*
Ethereum
)
ProcessPeerList
(
addrs
[]
string
)
{
func
(
s
*
Ethereum
)
ProcessPeerList
(
addrs
[]
string
)
{
...
@@ -303,12 +305,26 @@ func (s *Ethereum) Peers() *list.List {
...
@@ -303,12 +305,26 @@ func (s *Ethereum) Peers() *list.List {
}
}
func
(
s
*
Ethereum
)
reapPeers
()
{
func
(
s
*
Ethereum
)
reapPeers
()
{
eachPeer
(
s
.
peers
,
func
(
p
*
Peer
,
e
*
list
.
Element
)
{
if
atomic
.
LoadInt32
(
&
p
.
disconnect
)
==
1
||
(
p
.
inbound
&&
(
time
.
Now
()
.
Unix
()
-
p
.
lastPong
)
>
int64
(
5
*
time
.
Minute
))
{
s
.
removePeerElement
(
e
)
}
})
}
func
(
s
*
Ethereum
)
removePeerElement
(
e
*
list
.
Element
)
{
s
.
peerMut
.
Lock
()
s
.
peerMut
.
Lock
()
defer
s
.
peerMut
.
Unlock
()
defer
s
.
peerMut
.
Unlock
()
eachPeer
(
s
.
peers
,
func
(
p
*
Peer
,
e
*
list
.
Element
)
{
if
atomic
.
LoadInt32
(
&
p
.
disconnect
)
==
1
||
(
p
.
inbound
&&
(
time
.
Now
()
.
Unix
()
-
p
.
lastPong
)
>
int64
(
5
*
time
.
Minute
))
{
s
.
peers
.
Remove
(
e
)
s
.
peers
.
Remove
(
e
)
s
.
reactor
.
Post
(
"peerList"
,
s
.
peers
)
}
func
(
s
*
Ethereum
)
RemovePeer
(
p
*
Peer
)
{
eachPeer
(
s
.
peers
,
func
(
peer
*
Peer
,
e
*
list
.
Element
)
{
if
peer
==
p
{
s
.
removePeerElement
(
e
)
}
}
})
})
}
}
...
...
peer.go
View file @
f382221b
...
@@ -2,7 +2,6 @@ package eth
...
@@ -2,7 +2,6 @@ package eth
import
(
import
(
"bytes"
"bytes"
"container/list"
"fmt"
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
...
@@ -523,13 +522,7 @@ func (p *Peer) Stop() {
...
@@ -523,13 +522,7 @@ func (p *Peer) Stop() {
}
}
// Pre-emptively remove the peer; don't wait for reaping. We already know it's dead if we are here
// Pre-emptively remove the peer; don't wait for reaping. We already know it's dead if we are here
p
.
ethereum
.
peerMut
.
Lock
()
p
.
ethereum
.
RemovePeer
(
p
)
defer
p
.
ethereum
.
peerMut
.
Unlock
()
eachPeer
(
p
.
ethereum
.
peers
,
func
(
peer
*
Peer
,
e
*
list
.
Element
)
{
if
peer
==
p
{
p
.
ethereum
.
peers
.
Remove
(
e
)
}
})
}
}
func
(
p
*
Peer
)
pushHandshake
()
error
{
func
(
p
*
Peer
)
pushHandshake
()
error
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment