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
35ddf362
Unverified
Commit
35ddf362
authored
Jul 20, 2020
by
Péter Szilágyi
Committed by
GitHub
Jul 20, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21347 from karalabe/ethstats-fixes
ethstats: fix reconnection issue, implement primus pings
parents
9e88224e
0fef66c7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
ethstats.go
ethstats/ethstats.go
+19
-2
No files found.
ethstats/ethstats.go
View file @
35ddf362
...
...
@@ -280,8 +280,10 @@ func (s *Service) loop() {
}
}
fullReport
.
Stop
()
// Make sure the connection is closed
// Close the current connection and establish a new one
conn
.
Close
()
errTimer
.
Reset
(
0
)
}
}
}
...
...
@@ -296,8 +298,23 @@ func (s *Service) readLoop(conn *websocket.Conn) {
for
{
// Retrieve the next generic network packet and bail out on error
var
blob
json
.
RawMessage
if
err
:=
conn
.
ReadJSON
(
&
blob
);
err
!=
nil
{
log
.
Warn
(
"Failed to retrieve stats server message"
,
"err"
,
err
)
return
}
// If the network packet is a system ping, respond to it directly
var
ping
string
if
err
:=
json
.
Unmarshal
(
blob
,
&
ping
);
err
==
nil
&&
strings
.
HasPrefix
(
ping
,
"primus::ping::"
)
{
if
err
:=
conn
.
WriteJSON
(
strings
.
Replace
(
ping
,
"ping"
,
"pong"
,
-
1
));
err
!=
nil
{
log
.
Warn
(
"Failed to respond to system ping message"
,
"err"
,
err
)
return
}
continue
}
// Not a system ping, try to decode an actual state message
var
msg
map
[
string
][]
interface
{}
if
err
:=
conn
.
ReadJSON
(
&
msg
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
blob
,
&
msg
);
err
!=
nil
{
log
.
Warn
(
"Failed to decode stats server message"
,
"err"
,
err
)
return
}
...
...
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