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
3c1cccc8
Commit
3c1cccc8
authored
Jun 10, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: fetch the block hashes on the fly, when needed
parent
c4af70d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
9 deletions
+5
-9
downloader.go
eth/downloader/downloader.go
+5
-9
No files found.
eth/downloader/downloader.go
View file @
3c1cccc8
...
...
@@ -79,9 +79,9 @@ type Downloader struct {
banned
*
set
.
Set
// Set of hashes we've received and banned
// Statistics
importStart
time
.
Time
// Instance when the last blocks were taken from the cache
importQueue
[]
common
.
Hash
// Hashes of the p
reviously taken blocks to check import progress
importDone
int
// Number of taken blocks already imported from the last batch
importStart
time
.
Time
// Instance when the last blocks were taken from the cache
importQueue
[]
*
Block
// P
reviously taken blocks to check import progress
importDone
int
// Number of taken blocks already imported from the last batch
importLock
sync
.
Mutex
// Callbacks
...
...
@@ -136,7 +136,7 @@ func (d *Downloader) Stats() (pending int, cached int, importing int, estimate t
d
.
importLock
.
Lock
()
defer
d
.
importLock
.
Unlock
()
for
len
(
d
.
importQueue
)
>
0
&&
d
.
hasBlock
(
d
.
importQueue
[
0
])
{
for
len
(
d
.
importQueue
)
>
0
&&
d
.
hasBlock
(
d
.
importQueue
[
0
]
.
RawBlock
.
Hash
()
)
{
d
.
importQueue
=
d
.
importQueue
[
1
:
]
d
.
importDone
++
}
...
...
@@ -229,13 +229,9 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error {
func
(
d
*
Downloader
)
TakeBlocks
()
[]
*
Block
{
blocks
:=
d
.
queue
.
TakeBlocks
()
if
len
(
blocks
)
>
0
{
hashes
:=
make
([]
common
.
Hash
,
len
(
blocks
))
for
i
,
block
:=
range
blocks
{
hashes
[
i
]
=
block
.
RawBlock
.
Hash
()
}
d
.
importLock
.
Lock
()
d
.
importStart
=
time
.
Now
()
d
.
importQueue
=
hashe
s
d
.
importQueue
=
block
s
d
.
importDone
=
0
d
.
importLock
.
Unlock
()
}
...
...
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