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
5e5f3861
Commit
5e5f3861
authored
Jan 17, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed InOutMsg to msg
parent
87434a09
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
peer.go
peer.go
+8
-8
No files found.
peer.go
View file @
5e5f3861
...
@@ -20,7 +20,7 @@ type Peer struct {
...
@@ -20,7 +20,7 @@ type Peer struct {
// Net connection
// Net connection
conn
net
.
Conn
conn
net
.
Conn
// Output queue which is used to communicate and handle messages
// Output queue which is used to communicate and handle messages
outputQueue
chan
*
ethwire
.
InOut
Msg
outputQueue
chan
*
ethwire
.
Msg
// Quit channel
// Quit channel
quit
chan
bool
quit
chan
bool
// Determines whether it's an inbound or outbound peer
// Determines whether it's an inbound or outbound peer
...
@@ -41,7 +41,7 @@ type Peer struct {
...
@@ -41,7 +41,7 @@ type Peer struct {
func
NewPeer
(
conn
net
.
Conn
,
server
*
Server
,
inbound
bool
)
*
Peer
{
func
NewPeer
(
conn
net
.
Conn
,
server
*
Server
,
inbound
bool
)
*
Peer
{
return
&
Peer
{
return
&
Peer
{
outputQueue
:
make
(
chan
*
ethwire
.
InOut
Msg
,
outputBufferSize
),
outputQueue
:
make
(
chan
*
ethwire
.
Msg
,
outputBufferSize
),
quit
:
make
(
chan
bool
),
quit
:
make
(
chan
bool
),
server
:
server
,
server
:
server
,
conn
:
conn
,
conn
:
conn
,
...
@@ -53,7 +53,7 @@ func NewPeer(conn net.Conn, server *Server, inbound bool) *Peer {
...
@@ -53,7 +53,7 @@ func NewPeer(conn net.Conn, server *Server, inbound bool) *Peer {
func
NewOutboundPeer
(
addr
string
,
server
*
Server
)
*
Peer
{
func
NewOutboundPeer
(
addr
string
,
server
*
Server
)
*
Peer
{
p
:=
&
Peer
{
p
:=
&
Peer
{
outputQueue
:
make
(
chan
*
ethwire
.
InOut
Msg
,
outputBufferSize
),
outputQueue
:
make
(
chan
*
ethwire
.
Msg
,
outputBufferSize
),
quit
:
make
(
chan
bool
),
quit
:
make
(
chan
bool
),
server
:
server
,
server
:
server
,
inbound
:
false
,
inbound
:
false
,
...
@@ -82,11 +82,11 @@ func NewOutboundPeer(addr string, server *Server) *Peer {
...
@@ -82,11 +82,11 @@ func NewOutboundPeer(addr string, server *Server) *Peer {
}
}
// Outputs any RLP encoded data to the peer
// Outputs any RLP encoded data to the peer
func
(
p
*
Peer
)
QueueMessage
(
msg
*
ethwire
.
InOut
Msg
)
{
func
(
p
*
Peer
)
QueueMessage
(
msg
*
ethwire
.
Msg
)
{
p
.
outputQueue
<-
msg
p
.
outputQueue
<-
msg
}
}
func
(
p
*
Peer
)
writeMessage
(
msg
*
ethwire
.
InOut
Msg
)
{
func
(
p
*
Peer
)
writeMessage
(
msg
*
ethwire
.
Msg
)
{
// Ignore the write if we're not connected
// Ignore the write if we're not connected
if
atomic
.
LoadInt32
(
&
p
.
connected
)
!=
1
{
if
atomic
.
LoadInt32
(
&
p
.
connected
)
!=
1
{
return
return
...
@@ -123,7 +123,7 @@ out:
...
@@ -123,7 +123,7 @@ out:
p
.
lastSend
=
time
.
Now
()
p
.
lastSend
=
time
.
Now
()
case
<-
tickleTimer
.
C
:
case
<-
tickleTimer
.
C
:
p
.
writeMessage
(
&
ethwire
.
InOut
Msg
{
Type
:
ethwire
.
MsgPingTy
})
p
.
writeMessage
(
&
ethwire
.
Msg
{
Type
:
ethwire
.
MsgPingTy
})
// Break out of the for loop if a quit message is posted
// Break out of the for loop if a quit message is posted
case
<-
p
.
quit
:
case
<-
p
.
quit
:
...
@@ -177,7 +177,7 @@ out:
...
@@ -177,7 +177,7 @@ out:
case
ethwire
.
MsgPeersTy
:
case
ethwire
.
MsgPeersTy
:
case
ethwire
.
MsgPingTy
:
case
ethwire
.
MsgPingTy
:
// Respond back with pong
// Respond back with pong
p
.
writeMessage
(
&
ethwire
.
InOut
Msg
{
Type
:
ethwire
.
MsgPongTy
})
p
.
writeMessage
(
&
ethwire
.
Msg
{
Type
:
ethwire
.
MsgPongTy
})
case
ethwire
.
MsgPongTy
:
case
ethwire
.
MsgPongTy
:
p
.
lastPong
=
time
.
Now
()
.
Unix
()
p
.
lastPong
=
time
.
Now
()
.
Unix
()
...
@@ -231,7 +231,7 @@ func (p *Peer) pushHandshake() error {
...
@@ -231,7 +231,7 @@ func (p *Peer) pushHandshake() error {
return
nil
return
nil
}
}
func
(
p
*
Peer
)
handleHandshake
(
msg
*
ethwire
.
InOut
Msg
)
{
func
(
p
*
Peer
)
handleHandshake
(
msg
*
ethwire
.
Msg
)
{
c
:=
ethutil
.
Conv
(
msg
.
Data
)
c
:=
ethutil
.
Conv
(
msg
.
Data
)
// [PROTOCOL_VERSION, NETWORK_ID, CLIENT_ID]
// [PROTOCOL_VERSION, NETWORK_ID, CLIENT_ID]
if
c
.
Get
(
2
)
.
AsUint
()
==
p
.
server
.
Nonce
{
if
c
.
Get
(
2
)
.
AsUint
()
==
p
.
server
.
Nonce
{
...
...
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