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
8216bb90
Commit
8216bb90
authored
Jun 08, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth: clean up pending announce download map, polish logs
parent
9ed166c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
+26
-14
handler.go
eth/handler.go
+1
-1
sync.go
eth/sync.go
+25
-13
No files found.
eth/handler.go
View file @
8216bb90
...
...
@@ -362,7 +362,7 @@ func (pm *ProtocolManager) importBlock(p *peer, block *types.Block, td *big.Int)
_
,
chainHead
,
_
:=
pm
.
chainman
.
Status
()
jsonlogger
.
LogJson
(
&
logger
.
EthChainReceivedNewBlock
{
BlockHash
:
hash
.
Hex
(),
BlockNumber
:
block
.
Number
(),
// this surely must be zero
BlockNumber
:
block
.
Number
(),
ChainHeadHash
:
chainHead
.
Hex
(),
BlockPrevHash
:
block
.
ParentHash
()
.
Hex
(),
RemoteId
:
p
.
ID
()
.
String
(),
...
...
eth/sync.go
View file @
8216bb90
...
...
@@ -43,7 +43,7 @@ func (pm *ProtocolManager) fetcher() {
select
{
case
notifications
:=
<-
pm
.
newHashCh
:
// A batch of hashes the notified, schedule them for retrieval
glog
.
V
(
logger
.
De
tail
)
.
Infof
(
"Scheduling %d hash announce
s from %s"
,
len
(
notifications
),
notifications
[
0
]
.
peer
.
id
)
glog
.
V
(
logger
.
De
bug
)
.
Infof
(
"Scheduling %d hash announcement
s from %s"
,
len
(
notifications
),
notifications
[
0
]
.
peer
.
id
)
for
_
,
announce
:=
range
notifications
{
announces
[
announce
.
hash
]
=
announce
}
...
...
@@ -70,13 +70,13 @@ func (pm *ProtocolManager) fetcher() {
}
// Send out all block requests
for
peer
,
hashes
:=
range
request
{
glog
.
V
(
logger
.
De
tail
)
.
Infof
(
"Fetching specific
%d blocks from %s"
,
len
(
hashes
),
peer
.
id
)
glog
.
V
(
logger
.
De
bug
)
.
Infof
(
"Explicitly fetching
%d blocks from %s"
,
len
(
hashes
),
peer
.
id
)
peer
.
requestBlocks
(
hashes
)
}
request
=
make
(
map
[
*
peer
][]
common
.
Hash
)
case
filter
:=
<-
pm
.
newBlockCh
:
// Blocks arrived, extract any explicit
request
s, return all else
// Blocks arrived, extract any explicit
fetche
s, return all else
var
blocks
types
.
Blocks
select
{
case
blocks
=
<-
filter
:
...
...
@@ -84,26 +84,38 @@ func (pm *ProtocolManager) fetcher() {
return
}
fetch
,
sync
:=
[]
*
types
.
Block
{},
[]
*
types
.
Block
{}
explicit
,
download
:=
[]
*
types
.
Block
{},
[]
*
types
.
Block
{}
for
_
,
block
:=
range
blocks
{
hash
:=
block
.
Hash
()
// Filter explicitly requested blocks from hash announcements
if
_
,
ok
:=
pending
[
hash
];
ok
{
fetch
=
append
(
fetch
,
block
)
// Discard if already imported by other means
if
!
pm
.
chainman
.
HasBlock
(
hash
)
{
explicit
=
append
(
explicit
,
block
)
}
else
{
delete
(
pending
,
hash
)
}
}
else
{
sync
=
append
(
sync
,
block
)
download
=
append
(
download
,
block
)
}
}
select
{
case
filter
<-
sync
:
case
filter
<-
download
:
case
<-
pm
.
quitSync
:
return
}
// If any explicit fetches were replied to, import them
if
len
(
fetch
)
>
0
{
if
count
:=
len
(
explicit
);
count
>
0
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Importing %d explicitly fetched blocks"
,
count
)
go
func
()
{
for
_
,
block
:=
range
fetch
{
if
announce
:=
pending
[
block
.
Hash
()];
announce
!=
nil
{
for
_
,
block
:=
range
explicit
{
hash
:=
block
.
Hash
()
// Make sure there's still something pending to import
if
announce
:=
pending
[
hash
];
announce
!=
nil
{
delete
(
pending
,
hash
)
if
err
:=
pm
.
importBlock
(
announce
.
peer
,
block
,
nil
);
err
!=
nil
{
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"Failed to import explicitly fetched block: %v"
,
err
)
return
...
...
@@ -207,15 +219,15 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
return
}
// Get the hashes from the peer (synchronously)
glog
.
V
(
logger
.
De
bug
)
.
Infof
(
"Attempting synchronisation: %v, 0x%x"
,
peer
.
id
,
peer
.
recentHash
)
glog
.
V
(
logger
.
De
tail
)
.
Infof
(
"Attempting synchronisation: %v, 0x%x"
,
peer
.
id
,
peer
.
recentHash
)
err
:=
pm
.
downloader
.
Synchronise
(
peer
.
id
,
peer
.
recentHash
)
switch
err
{
case
nil
:
glog
.
V
(
logger
.
De
bug
)
.
Infof
(
"Synchronisation completed"
)
glog
.
V
(
logger
.
De
tail
)
.
Infof
(
"Synchronisation completed"
)
case
downloader
.
ErrBusy
:
glog
.
V
(
logger
.
De
bug
)
.
Infof
(
"Synchronisation already in progress"
)
glog
.
V
(
logger
.
De
tail
)
.
Infof
(
"Synchronisation already in progress"
)
case
downloader
.
ErrTimeout
,
downloader
.
ErrBadPeer
,
downloader
.
ErrEmptyHashSet
,
downloader
.
ErrInvalidChain
,
downloader
.
ErrCrossCheckFailed
:
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Removing peer %v: %v"
,
peer
.
id
,
err
)
...
...
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