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
7931c662
Commit
7931c662
authored
Jan 25, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graceful shutdown of peers
parent
1b7cba18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
peer.go
peer.go
+20
-13
No files found.
peer.go
View file @
7931c662
...
...
@@ -169,17 +169,26 @@ out:
case
ethwire
.
MsgHandshakeTy
:
// Version message
p
.
handleHandshake
(
msg
)
case
ethwire
.
MsgDiscTy
:
p
.
Stop
()
case
ethwire
.
MsgPingTy
:
// Respond back with pong
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgPongTy
,
""
))
case
ethwire
.
MsgPongTy
:
p
.
lastPong
=
time
.
Now
()
.
Unix
()
case
ethwire
.
MsgBlockTy
:
block
:=
ethchain
.
NewBlockFromRlpValue
(
msg
.
Data
.
Get
(
0
))
block
.
MakeContracts
()
err
:=
p
.
ethereum
.
BlockManager
.
ProcessBlock
(
block
)
if
err
!=
nil
{
log
.
Println
(
err
)
for
i
:=
0
;
i
<
msg
.
Data
.
Length
();
i
++
{
block
:=
ethchain
.
NewBlockFromRlpValue
(
msg
.
Data
.
Get
(
i
))
err
:=
p
.
ethereum
.
BlockManager
.
ProcessBlock
(
block
)
if
err
!=
nil
{
log
.
Println
(
err
)
}
}
case
ethwire
.
MsgTxTy
:
//p.ethereum.TxPool.QueueTransaction(ethchain.NewTransactionFromData(msg.Data))
p
.
ethereum
.
TxPool
.
QueueTransaction
(
ethchain
.
NewTransactionFromRlpValue
(
msg
.
Data
.
Get
(
0
)))
case
ethwire
.
MsgInvTy
:
for
i
:=
0
;
i
<
msg
.
Data
.
Length
();
i
++
{
p
.
ethereum
.
TxPool
.
QueueTransaction
(
ethchain
.
NewTransactionFromRlpValue
(
msg
.
Data
.
Get
(
i
)))
}
case
ethwire
.
MsgGetPeersTy
:
p
.
requestedPeerList
=
true
// Peer asked for list of connected peers
...
...
@@ -201,11 +210,8 @@ out:
// Mark unrequested again
p
.
requestedPeerList
=
false
}
case
ethwire
.
MsgPingTy
:
// Respond back with pong
p
.
QueueMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgPongTy
,
""
))
case
ethwire
.
MsgPongTy
:
p
.
lastPong
=
time
.
Now
()
.
Unix
()
case
ethwire
.
MsgGetChainTy
:
}
}
...
...
@@ -235,6 +241,7 @@ func (p *Peer) Stop() {
close
(
p
.
quit
)
if
atomic
.
LoadInt32
(
&
p
.
connected
)
!=
0
{
p
.
writeMessage
(
ethwire
.
NewMessage
(
ethwire
.
MsgDiscTy
,
""
))
p
.
conn
.
Close
()
}
...
...
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