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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
aa934157
Commit
aa934157
authored
Feb 2, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Disconnection reasons
parent
f4a96ca5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
peer.go
+38
-13
38 additions, 13 deletions
peer.go
with
38 additions
and
13 deletions
peer.go
+
38
−
13
View file @
aa934157
...
...
@@ -17,27 +17,53 @@ const (
outputBufferSize
=
50
)
// Peer capabillities
type
DiscReason
byte
const
(
DiscReRequested
=
0x00
DiscReTcpSysErr
=
0x01
DiscBadProto
=
0x02
DiscBadPeer
=
0x03
DiscTooManyPeers
=
0x04
)
var
discReasonToString
=
[]
string
{
"Disconnect requested"
,
"Disconnect TCP sys error"
,
"Disconnect Bad protocol"
,
"Disconnect Useless peer"
,
"Disconnect Too many peers"
,
}
func
(
d
DiscReason
)
String
()
string
{
if
len
(
discReasonToString
)
>
int
(
d
)
{
return
"Unknown"
}
return
discReasonToString
[
d
]
}
// Peer capabilities
type
Caps
byte
const
(
CapDisc
overy
Ty
=
0x01
Cap
Peer
DiscTy
=
0x01
CapTxTy
=
0x02
CapChainTy
=
0x04
CapDefault
=
CapChainTy
|
CapTxTy
|
CapDisc
overy
Ty
CapDefault
=
CapChainTy
|
CapTxTy
|
Cap
Peer
DiscTy
)
var
capsToString
=
map
[
Caps
]
string
{
CapDisc
overy
Ty
:
"Peer discovery"
,
Cap
Peer
DiscTy
:
"Peer discovery"
,
CapTxTy
:
"Transaction relaying"
,
CapChainTy
:
"Block chain relaying"
,
}
func
(
c
Caps
)
String
()
string
{
var
caps
[]
string
if
c
&
CapDisc
overy
Ty
>
0
{
caps
=
append
(
caps
,
capsToString
[
CapDisc
overy
Ty
])
if
c
&
Cap
Peer
DiscTy
>
0
{
caps
=
append
(
caps
,
capsToString
[
Cap
Peer
DiscTy
])
}
if
c
&
CapChainTy
>
0
{
caps
=
append
(
caps
,
capsToString
[
CapChainTy
])
...
...
@@ -175,7 +201,7 @@ out:
// Service timer takes care of peer broadcasting, transaction
// posting or block posting
case
<-
serviceTimer
.
C
:
if
p
.
caps
&
CapDisc
overy
Ty
>
0
{
if
p
.
caps
&
Cap
Peer
DiscTy
>
0
{
msg
:=
p
.
peersMessage
()
p
.
ethereum
.
BroadcastMsg
(
msg
)
}
...
...
@@ -220,6 +246,7 @@ out:
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgGetPeersTy
,
""
))
case
ethwire
.
MsgDiscTy
:
p
.
Stop
()
log
.
Println
(
"Disconnect peer:"
,
DiscReason
(
msg
.
Data
.
Get
(
0
)
.
AsUint
()))
case
ethwire
.
MsgPingTy
:
// Respond back with pong
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgPongTy
,
""
))
...
...
@@ -381,8 +408,6 @@ func (p *Peer) Stop() {
p
.
writeMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgDiscTy
,
""
))
p
.
conn
.
Close
()
}
log
.
Println
(
"Peer shutdown"
)
}
func
(
p
*
Peer
)
pushHandshake
()
error
{
...
...
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