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
3dbd3209
Commit
3dbd3209
authored
Feb 19, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: enable devp2p ping
This should prevent connection drops.
parent
1ec6190e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
+26
-11
peer.go
p2p/peer.go
+26
-11
No files found.
p2p/peer.go
View file @
3dbd3209
...
...
@@ -21,6 +21,7 @@ const (
baseProtocolMaxMsgSize
=
10
*
1024
*
1024
disconnectGracePeriod
=
2
*
time
.
Second
pingInterval
=
15
*
time
.
Second
)
const
(
...
...
@@ -118,19 +119,33 @@ func (p *Peer) run() DiscReason {
p
.
startProtocols
()
go
func
()
{
readErr
<-
p
.
readLoop
()
}()
ping
:=
time
.
NewTicker
(
pingInterval
)
defer
ping
.
Stop
()
// Wait for an error or disconnect.
var
reason
DiscReason
loop
:
for
{
select
{
case
<-
ping
.
C
:
go
func
()
{
if
err
:=
EncodeMsg
(
p
.
rw
,
pingMsg
,
nil
);
err
!=
nil
{
p
.
protoErr
<-
err
return
}
}()
case
err
:=
<-
readErr
:
// We rely on protocols to abort if there is a write error. It
// might be more robust to handle them here as well.
p
.
DebugDetailf
(
"Read error: %v
\n
"
,
err
)
p
.
rw
.
Close
()
return
DiscNetworkError
case
err
:=
<-
p
.
protoErr
:
reason
=
discReasonForError
(
err
)
break
loop
case
reason
=
<-
p
.
disc
:
break
loop
}
}
p
.
politeDisconnect
(
reason
)
...
...
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