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
8fdbbef7
Unverified
Commit
8fdbbef7
authored
Nov 28, 2018
by
Péter Szilágyi
Committed by
GitHub
Nov 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18196 from karalabe/downloader-cht-fix
eth/downloader: fix light client cht binary search issue
parents
86969865
174083c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
downloader.go
eth/downloader/downloader.go
+22
-0
No files found.
eth/downloader/downloader.go
View file @
8fdbbef7
...
...
@@ -99,6 +99,7 @@ type Downloader struct {
mode
SyncMode
// Synchronisation mode defining the strategy used (per sync cycle)
mux
*
event
.
TypeMux
// Event multiplexer to announce sync operation events
genesis
uint64
// Genesis block number to limit sync to (e.g. light client CHT)
queue
*
queue
// Scheduler for selecting the hashes to download
peers
*
peerSet
// Set of active peers from which download can proceed
stateDB
ethdb
.
Database
...
...
@@ -664,7 +665,28 @@ func (d *Downloader) findAncestor(p *peerConnection, remoteHeader *types.Header)
}
p
.
log
.
Debug
(
"Looking for common ancestor"
,
"local"
,
localHeight
,
"remote"
,
remoteHeight
)
if
localHeight
>=
MaxForkAncestry
{
// We're above the max reorg threshold, find the earliest fork point
floor
=
int64
(
localHeight
-
MaxForkAncestry
)
// If we're doing a light sync, ensure the floor doesn't go below the CHT, as
// all headers before that point will be missing.
if
d
.
mode
==
LightSync
{
// If we dont know the current CHT position, find it
if
d
.
genesis
==
0
{
header
:=
d
.
lightchain
.
CurrentHeader
()
for
header
!=
nil
{
d
.
genesis
=
header
.
Number
.
Uint64
()
if
floor
>=
int64
(
d
.
genesis
)
-
1
{
break
}
header
=
d
.
lightchain
.
GetHeaderByHash
(
header
.
ParentHash
)
}
}
// We already know the "genesis" block number, cap floor to that
if
floor
<
int64
(
d
.
genesis
)
-
1
{
floor
=
int64
(
d
.
genesis
)
-
1
}
}
}
from
,
count
,
skip
,
max
:=
calculateRequestSpan
(
remoteHeight
,
localHeight
)
...
...
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