good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
87434a09
Commit
87434a09
authored
11 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Ping pong message
parent
ddf82c33
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
peer.go
+7
-1
7 additions, 1 deletion
peer.go
server.go
+2
-2
2 additions, 2 deletions
server.go
with
9 additions
and
3 deletions
peer.go
+
7
−
1
View file @
87434a09
...
...
@@ -34,6 +34,9 @@ type Peer struct {
// This flag is used by writeMessage to check if messages are allowed
// to be send or not. If no version is known all messages are ignored.
versionKnown
bool
// Last received pong message
lastPong
int64
}
func
NewPeer
(
conn
net
.
Conn
,
server
*
Server
,
inbound
bool
)
*
Peer
{
...
...
@@ -109,7 +112,7 @@ func (p *Peer) writeMessage(msg *ethwire.InOutMsg) {
// Outbound message handler. Outbound messages are handled here
func
(
p
*
Peer
)
HandleOutbound
()
{
// The ping timer. Makes sure that every 2 minutes a ping is send to the peer
tickleTimer
:=
time
.
NewTi
m
er
(
2
*
time
.
Minute
)
tickleTimer
:=
time
.
NewTi
ck
er
(
2
*
time
.
Minute
)
out
:
for
{
select
{
...
...
@@ -173,7 +176,10 @@ out:
case
ethwire
.
MsgGetPeersTy
:
case
ethwire
.
MsgPeersTy
:
case
ethwire
.
MsgPingTy
:
// Respond back with pong
p
.
writeMessage
(
&
ethwire
.
InOutMsg
{
Type
:
ethwire
.
MsgPongTy
})
case
ethwire
.
MsgPongTy
:
p
.
lastPong
=
time
.
Now
()
.
Unix
()
/*
case "blockmine":
...
...
This diff is collapsed.
Click to expand it.
server.go
+
2
−
2
View file @
87434a09
...
...
@@ -81,13 +81,13 @@ func (s *Server) Broadcast(msgType ethwire.MsgType, data []byte) {
}
const
(
processReapingTimeout
=
1
0
// TODO increase
processReapingTimeout
=
1
// TODO increase
)
func
(
s
*
Server
)
ReapDeadPeers
()
{
for
{
eachPeer
(
s
.
peers
,
func
(
p
*
Peer
,
e
*
list
.
Element
)
{
if
atomic
.
LoadInt32
(
&
p
.
disconnect
)
==
1
{
if
atomic
.
LoadInt32
(
&
p
.
disconnect
)
==
1
||
(
p
.
inbound
&&
(
time
.
Now
()
.
Unix
()
-
p
.
lastPong
)
>
int64
(
5
*
time
.
Minute
))
{
log
.
Println
(
"Dead peer found .. reaping"
)
s
.
peers
.
Remove
(
e
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment