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
fb835c02
Unverified
Commit
fb835c02
authored
Sep 08, 2020
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: dynamically move pivot even during chain sync
parent
faba018b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
192 additions
and
72 deletions
+192
-72
downloader.go
eth/downloader/downloader.go
+172
-53
downloader_test.go
eth/downloader/downloader_test.go
+3
-11
testchain_test.go
eth/downloader/testchain_test.go
+17
-8
No files found.
eth/downloader/downloader.go
View file @
fb835c02
This diff is collapsed.
Click to expand it.
eth/downloader/downloader_test.go
View file @
fb835c02
...
...
@@ -427,11 +427,7 @@ func (dlp *downloadTesterPeer) Head() (common.Hash, *big.Int) {
// origin; associated with a particular peer in the download tester. The returned
// function can be used to retrieve batches of headers from the particular peer.
func
(
dlp
*
downloadTesterPeer
)
RequestHeadersByHash
(
origin
common
.
Hash
,
amount
int
,
skip
int
,
reverse
bool
)
error
{
if
reverse
{
panic
(
"reverse header requests not supported"
)
}
result
:=
dlp
.
chain
.
headersByHash
(
origin
,
amount
,
skip
)
result
:=
dlp
.
chain
.
headersByHash
(
origin
,
amount
,
skip
,
reverse
)
go
dlp
.
dl
.
downloader
.
DeliverHeaders
(
dlp
.
id
,
result
)
return
nil
}
...
...
@@ -440,11 +436,7 @@ func (dlp *downloadTesterPeer) RequestHeadersByHash(origin common.Hash, amount i
// origin; associated with a particular peer in the download tester. The returned
// function can be used to retrieve batches of headers from the particular peer.
func
(
dlp
*
downloadTesterPeer
)
RequestHeadersByNumber
(
origin
uint64
,
amount
int
,
skip
int
,
reverse
bool
)
error
{
if
reverse
{
panic
(
"reverse header requests not supported"
)
}
result
:=
dlp
.
chain
.
headersByNumber
(
origin
,
amount
,
skip
)
result
:=
dlp
.
chain
.
headersByNumber
(
origin
,
amount
,
skip
,
reverse
)
go
dlp
.
dl
.
downloader
.
DeliverHeaders
(
dlp
.
id
,
result
)
return
nil
}
...
...
@@ -1698,7 +1690,7 @@ func testCheckpointEnforcement(t *testing.T, protocol int, mode SyncMode) {
if
mode
==
FastSync
||
mode
==
LightSync
{
expect
=
errUnsyncedPeer
}
if
err
:=
tester
.
sync
(
"peer"
,
nil
,
mode
);
err
!=
expect
{
if
err
:=
tester
.
sync
(
"peer"
,
nil
,
mode
);
!
errors
.
Is
(
err
,
expect
)
{
t
.
Fatalf
(
"block sync error mismatch: have %v, want %v"
,
err
,
expect
)
}
if
mode
==
FastSync
||
mode
==
LightSync
{
...
...
eth/downloader/testchain_test.go
View file @
fb835c02
...
...
@@ -170,18 +170,27 @@ func (tc *testChain) td(hash common.Hash) *big.Int {
return
tc
.
tdm
[
hash
]
}
// headersByHash returns headers in
ascending
order from the given hash.
func
(
tc
*
testChain
)
headersByHash
(
origin
common
.
Hash
,
amount
int
,
skip
int
)
[]
*
types
.
Header
{
// headersByHash returns headers in order from the given hash.
func
(
tc
*
testChain
)
headersByHash
(
origin
common
.
Hash
,
amount
int
,
skip
int
,
reverse
bool
)
[]
*
types
.
Header
{
num
,
_
:=
tc
.
hashToNumber
(
origin
)
return
tc
.
headersByNumber
(
num
,
amount
,
skip
)
return
tc
.
headersByNumber
(
num
,
amount
,
skip
,
reverse
)
}
// headersByNumber returns headers
in ascending order
from the given number.
func
(
tc
*
testChain
)
headersByNumber
(
origin
uint64
,
amount
int
,
skip
int
)
[]
*
types
.
Header
{
// headersByNumber returns headers from the given number.
func
(
tc
*
testChain
)
headersByNumber
(
origin
uint64
,
amount
int
,
skip
int
,
reverse
bool
)
[]
*
types
.
Header
{
result
:=
make
([]
*
types
.
Header
,
0
,
amount
)
for
num
:=
origin
;
num
<
uint64
(
len
(
tc
.
chain
))
&&
len
(
result
)
<
amount
;
num
+=
uint64
(
skip
)
+
1
{
if
header
,
ok
:=
tc
.
headerm
[
tc
.
chain
[
int
(
num
)]];
ok
{
result
=
append
(
result
,
header
)
if
!
reverse
{
for
num
:=
origin
;
num
<
uint64
(
len
(
tc
.
chain
))
&&
len
(
result
)
<
amount
;
num
+=
uint64
(
skip
)
+
1
{
if
header
,
ok
:=
tc
.
headerm
[
tc
.
chain
[
int
(
num
)]];
ok
{
result
=
append
(
result
,
header
)
}
}
}
else
{
for
num
:=
int64
(
origin
);
num
>=
0
&&
len
(
result
)
<
amount
;
num
-=
int64
(
skip
)
+
1
{
if
header
,
ok
:=
tc
.
headerm
[
tc
.
chain
[
int
(
num
)]];
ok
{
result
=
append
(
result
,
header
)
}
}
}
return
result
...
...
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