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
8216bb90
Commit
8216bb90
authored
Jun 8, 2015
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth: clean up pending announce download map, polish logs
parent
9ed166c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
eth/handler.go
+1
-1
1 addition, 1 deletion
eth/handler.go
eth/sync.go
+25
-13
25 additions, 13 deletions
eth/sync.go
with
26 additions
and
14 deletions
eth/handler.go
+
1
−
1
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
(),
...
...
This diff is collapsed.
Click to expand it.
eth/sync.go
+
25
−
13
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 announces from %s"
,
len
(
notifications
),
notifications
[
0
]
.
peer
.
id
)
glog
.
V
(
logger
.
De
bug
)
.
Infof
(
"Scheduling %d hash announce
ment
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
)
...
...
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