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
f0f67277
Commit
f0f67277
authored
Dec 12, 2014
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: use an error type for disconnect requests
Test-tastic.
parent
65e39bf2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
peer_error.go
p2p/peer_error.go
+9
-0
protocol.go
p2p/protocol.go
+1
-2
No files found.
p2p/peer_error.go
View file @
f0f67277
...
@@ -100,7 +100,16 @@ func (d DiscReason) String() string {
...
@@ -100,7 +100,16 @@ func (d DiscReason) String() string {
return
discReasonToString
[
d
]
return
discReasonToString
[
d
]
}
}
type
discRequestedError
DiscReason
func
(
err
discRequestedError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"disconnect requested: %v"
,
DiscReason
(
err
))
}
func
discReasonForError
(
err
error
)
DiscReason
{
func
discReasonForError
(
err
error
)
DiscReason
{
if
reason
,
ok
:=
err
.
(
discRequestedError
);
ok
{
return
DiscReason
(
reason
)
}
peerError
,
ok
:=
err
.
(
*
peerError
)
peerError
,
ok
:=
err
.
(
*
peerError
)
if
!
ok
{
if
!
ok
{
return
DiscSubprotocolError
return
DiscSubprotocolError
...
...
p2p/protocol.go
View file @
f0f67277
...
@@ -158,8 +158,7 @@ func (bp *baseProtocol) handle(rw MsgReadWriter) error {
...
@@ -158,8 +158,7 @@ func (bp *baseProtocol) handle(rw MsgReadWriter) error {
if
err
:=
msg
.
Decode
(
&
reason
);
err
!=
nil
{
if
err
:=
msg
.
Decode
(
&
reason
);
err
!=
nil
{
return
err
return
err
}
}
bp
.
peer
.
Disconnect
(
reason
[
0
])
return
discRequestedError
(
reason
[
0
])
return
nil
case
pingMsg
:
case
pingMsg
:
return
bp
.
rw
.
EncodeMsg
(
pongMsg
)
return
bp
.
rw
.
EncodeMsg
(
pongMsg
)
...
...
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