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
3719db35
Commit
3719db35
authored
Feb 19, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: emit JSON connect/disconnect events
parent
fa15854a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
server.go
p2p/server.go
+13
-0
No files found.
p2p/server.go
View file @
3719db35
...
...
@@ -22,6 +22,7 @@ const (
)
var
srvlog
=
logger
.
NewLogger
(
"P2P Server"
)
var
srvjslog
=
logger
.
NewJsonLogger
()
// MakeName creates a node name that follows the ethereum convention
// for such names. It adds the operation system name and Go runtime version
...
...
@@ -370,14 +371,26 @@ func (srv *Server) startPeer(fd net.Conn, dest *discover.Node) {
p
.
politeDisconnect
(
reason
)
return
}
srvlog
.
Debugf
(
"Added %v
\n
"
,
p
)
srvjslog
.
LogJson
(
&
logger
.
P2PConnected
{
RemoteId
:
fmt
.
Sprintf
(
"%x"
,
conn
.
ID
[
:
]),
RemoteAddress
:
conn
.
RemoteAddr
()
.
String
(),
RemoteVersionString
:
conn
.
Name
,
NumConnections
:
srv
.
PeerCount
(),
})
if
srv
.
newPeerHook
!=
nil
{
srv
.
newPeerHook
(
p
)
}
discreason
:=
p
.
run
()
srv
.
removePeer
(
p
)
srvlog
.
Debugf
(
"Removed %v (%v)
\n
"
,
p
,
discreason
)
srvjslog
.
LogJson
(
&
logger
.
P2PDisconnected
{
RemoteId
:
fmt
.
Sprintf
(
"%x"
,
conn
.
ID
[
:
]),
NumConnections
:
srv
.
PeerCount
(),
})
}
func
(
srv
*
Server
)
addPeer
(
id
discover
.
NodeID
,
p
*
Peer
)
(
bool
,
DiscReason
)
{
...
...
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