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
d68865f3
Commit
d68865f3
authored
Jul 26, 2016
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth/downloader: fewer headers and futures too un ancestor lookup
parent
a724952f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth/downloader/downloader.go
+17
-9
17 additions, 9 deletions
eth/downloader/downloader.go
with
17 additions
and
9 deletions
eth/downloader/downloader.go
+
17
−
9
View file @
d68865f3
...
@@ -558,11 +558,17 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) {
...
@@ -558,11 +558,17 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) {
if
head
>
height
{
if
head
>
height
{
head
=
height
head
=
height
}
}
from
:=
int64
(
head
)
-
int64
(
MaxHeaderFetch
)
+
1
from
:=
int64
(
head
)
-
int64
(
MaxHeaderFetch
)
if
from
<
0
{
if
from
<
0
{
from
=
0
from
=
0
}
}
go
p
.
getAbsHeaders
(
uint64
(
from
),
MaxHeaderFetch
,
0
,
false
)
// Span out with 15 block gaps into the future to catch bad head reports
limit
:=
2
*
MaxHeaderFetch
/
16
count
:=
1
+
int
((
int64
(
ceil
)
-
from
)
/
16
)
if
count
>
limit
{
count
=
limit
}
go
p
.
getAbsHeaders
(
uint64
(
from
),
count
,
15
,
false
)
// Wait for the remote response to the head fetch
// Wait for the remote response to the head fetch
number
,
hash
:=
uint64
(
0
),
common
.
Hash
{}
number
,
hash
:=
uint64
(
0
),
common
.
Hash
{}
...
@@ -587,12 +593,8 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) {
...
@@ -587,12 +593,8 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) {
}
}
// Make sure the peer's reply conforms to the request
// Make sure the peer's reply conforms to the request
for
i
:=
0
;
i
<
len
(
headers
);
i
++
{
for
i
:=
0
;
i
<
len
(
headers
);
i
++
{
if
number
:=
headers
[
i
]
.
Number
.
Int64
();
number
!=
from
+
int64
(
i
)
{
if
number
:=
headers
[
i
]
.
Number
.
Int64
();
number
!=
from
+
int64
(
i
)
*
16
{
glog
.
V
(
logger
.
Warn
)
.
Infof
(
"%v: head header set (item %d) broke chain ordering: requested %d, got %d"
,
p
,
i
,
from
+
int64
(
i
),
number
)
glog
.
V
(
logger
.
Warn
)
.
Infof
(
"%v: head header set (item %d) broke chain ordering: requested %d, got %d"
,
p
,
i
,
from
+
int64
(
i
)
*
16
,
number
)
return
0
,
errInvalidChain
}
if
i
>
0
&&
headers
[
i
-
1
]
.
Hash
()
!=
headers
[
i
]
.
ParentHash
{
glog
.
V
(
logger
.
Warn
)
.
Infof
(
"%v: head header set (item %d) broke chain ancestry: expected [%x], got [%x]"
,
p
,
i
,
headers
[
i
-
1
]
.
Hash
()
.
Bytes
()[
:
4
],
headers
[
i
]
.
ParentHash
[
:
4
])
return
0
,
errInvalidChain
return
0
,
errInvalidChain
}
}
}
}
...
@@ -600,12 +602,18 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) {
...
@@ -600,12 +602,18 @@ func (d *Downloader) findAncestor(p *peer, height uint64) (uint64, error) {
finished
=
true
finished
=
true
for
i
:=
len
(
headers
)
-
1
;
i
>=
0
;
i
--
{
for
i
:=
len
(
headers
)
-
1
;
i
>=
0
;
i
--
{
// Skip any headers that underflow/overflow our requested set
// Skip any headers that underflow/overflow our requested set
if
headers
[
i
]
.
Number
.
Int64
()
<
from
||
headers
[
i
]
.
Number
.
Uint64
()
>
head
{
if
headers
[
i
]
.
Number
.
Int64
()
<
from
||
headers
[
i
]
.
Number
.
Uint64
()
>
ceil
{
continue
continue
}
}
// Otherwise check if we already know the header or not
// Otherwise check if we already know the header or not
if
(
d
.
mode
==
FullSync
&&
d
.
hasBlockAndState
(
headers
[
i
]
.
Hash
()))
||
(
d
.
mode
!=
FullSync
&&
d
.
hasHeader
(
headers
[
i
]
.
Hash
()))
{
if
(
d
.
mode
==
FullSync
&&
d
.
hasBlockAndState
(
headers
[
i
]
.
Hash
()))
||
(
d
.
mode
!=
FullSync
&&
d
.
hasHeader
(
headers
[
i
]
.
Hash
()))
{
number
,
hash
=
headers
[
i
]
.
Number
.
Uint64
(),
headers
[
i
]
.
Hash
()
number
,
hash
=
headers
[
i
]
.
Number
.
Uint64
(),
headers
[
i
]
.
Hash
()
// If every header is known, even future ones, the peer straight out lied about its head
if
number
>
height
&&
i
==
limit
-
1
{
glog
.
V
(
logger
.
Warn
)
.
Infof
(
"%v: lied about chain head: reported %d, found above %d"
,
p
,
height
,
number
)
return
0
,
errStallingPeer
}
break
break
}
}
}
}
...
...
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