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
d2edc2bb
Commit
d2edc2bb
authored
Feb 10, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some loggers
parent
8db7d791
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
peer.go
peer.go
+16
-8
No files found.
peer.go
View file @
d2edc2bb
...
...
@@ -26,14 +26,20 @@ const (
DiscBadProto
=
0x02
DiscBadPeer
=
0x03
DiscTooManyPeers
=
0x04
DiscConnDup
=
0x05
DiscGenesisErr
=
0x06
DiscProtoErr
=
0x07
)
var
discReasonToString
=
[]
string
{
"Disconnect requested"
,
"Disconnect TCP sys error"
,
"Disconnect Bad protocol"
,
"Disconnect Useless peer"
,
"Disconnect Too many peers"
,
"Disconnect bad protocol"
,
"Disconnect useless peer"
,
"Disconnect too many peers"
,
"Disconnect already connected"
,
"Disconnect wrong genesis block"
,
"Disconnect incompatible network"
,
}
func
(
d
DiscReason
)
String
()
string
{
...
...
@@ -241,7 +247,6 @@ clean:
// Inbound handler. Inbound messages are received here and passed to the appropriate methods
func
(
p
*
Peer
)
HandleInbound
()
{
out
:
for
atomic
.
LoadInt32
(
&
p
.
disconnect
)
==
0
{
// HMM?
time
.
Sleep
(
500
*
time
.
Millisecond
)
...
...
@@ -250,8 +255,6 @@ out:
msgs
,
err
:=
ethwire
.
ReadMessages
(
p
.
conn
)
if
err
!=
nil
{
log
.
Println
(
err
)
break
out
}
for
_
,
msg
:=
range
msgs
{
switch
msg
.
Type
{
...
...
@@ -276,9 +279,10 @@ out:
case
ethwire
.
MsgBlockTy
:
// Get all blocks and process them
msg
.
Data
=
msg
.
Data
var
block
*
ethchain
.
Block
for
i
:=
msg
.
Data
.
Length
()
-
1
;
i
>=
0
;
i
--
{
// FIXME
block
:
=
ethchain
.
NewBlockFromRlpValue
(
ethutil
.
NewValue
(
msg
.
Data
.
Get
(
i
)
.
AsRaw
()))
block
=
ethchain
.
NewBlockFromRlpValue
(
ethutil
.
NewValue
(
msg
.
Data
.
Get
(
i
)
.
AsRaw
()))
err
:=
p
.
ethereum
.
BlockManager
.
ProcessBlock
(
block
)
if
err
!=
nil
{
...
...
@@ -288,6 +292,10 @@ out:
// If we're catching up, try to catch up further.
if
p
.
catchingUp
&&
msg
.
Data
.
Length
()
>
1
{
if
ethutil
.
Config
.
Debug
{
blockInfo
:=
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
BlockInfo
(
block
)
log
.
Printf
(
"Synced to block height #%d
\n
"
,
blockInfo
.
Number
)
}
p
.
catchingUp
=
false
p
.
CatchupWithPeer
()
}
...
...
@@ -500,7 +508,7 @@ func (p *Peer) CatchupWithPeer() {
msg
:=
ethwire
.
NewMessage
(
ethwire
.
MsgGetChainTy
,
[]
interface
{}{
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
.
Hash
(),
uint64
(
50
)})
p
.
QueueMessage
(
msg
)
log
.
Printf
(
"Requesting blockchain
up from %x
\n
"
,
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
.
Hash
()
)
log
.
Printf
(
"Requesting blockchain
%x...
\n
"
,
p
.
ethereum
.
BlockManager
.
BlockChain
()
.
CurrentBlock
.
Hash
()[
:
4
]
)
}
}
...
...
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