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
271fb20e
Commit
271fb20e
authored
Jun 10, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth, eth/downloader: rough guess at the import eta
parent
b3d5ce7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
admin.go
cmd/geth/admin.go
+7
-2
downloader.go
eth/downloader/downloader.go
+13
-2
No files found.
cmd/geth/admin.go
View file @
271fb20e
...
...
@@ -325,8 +325,13 @@ func (js *jsre) setHead(call otto.FunctionCall) otto.Value {
}
func
(
js
*
jsre
)
syncProgress
(
call
otto
.
FunctionCall
)
otto
.
Value
{
pending
,
cached
,
importing
:=
js
.
ethereum
.
Downloader
()
.
Stats
()
v
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"pending"
:
pending
,
"cached"
:
cached
,
"importing"
:
importing
})
pending
,
cached
,
importing
,
eta
:=
js
.
ethereum
.
Downloader
()
.
Stats
()
v
,
_
:=
call
.
Otto
.
ToValue
(
map
[
string
]
interface
{}{
"pending"
:
pending
,
"cached"
:
cached
,
"importing"
:
importing
,
"estimate"
:
eta
.
String
(),
})
return
v
}
...
...
eth/downloader/downloader.go
View file @
271fb20e
...
...
@@ -79,7 +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 previously taken blocks to check import progress
importDone
int
// Number of taken blocks already imported from the last batch
importLock
sync
.
Mutex
// Callbacks
...
...
@@ -126,19 +128,25 @@ func New(mux *event.TypeMux, hasBlock hashCheckFn, getBlock getBlockFn) *Downloa
}
// Stats retrieves the current status of the downloader.
func
(
d
*
Downloader
)
Stats
()
(
pending
int
,
cached
int
,
importing
int
)
{
func
(
d
*
Downloader
)
Stats
()
(
pending
int
,
cached
int
,
importing
int
,
estimate
time
.
Duration
)
{
// Fetch the download status
pending
,
cached
=
d
.
queue
.
Size
()
//
Generate the import statu
s
//
Figure out the import progres
s
d
.
importLock
.
Lock
()
defer
d
.
importLock
.
Unlock
()
for
len
(
d
.
importQueue
)
>
0
&&
d
.
hasBlock
(
d
.
importQueue
[
0
])
{
d
.
importQueue
=
d
.
importQueue
[
1
:
]
d
.
importDone
++
}
importing
=
len
(
d
.
importQueue
)
// Make an estimate on the total sync
estimate
=
0
if
d
.
importDone
>
0
{
estimate
=
time
.
Since
(
d
.
importStart
)
/
time
.
Duration
(
d
.
importDone
)
*
time
.
Duration
(
pending
+
cached
+
importing
)
}
return
}
...
...
@@ -226,7 +234,9 @@ func (d *Downloader) TakeBlocks() []*Block {
hashes
[
i
]
=
block
.
RawBlock
.
Hash
()
}
d
.
importLock
.
Lock
()
d
.
importStart
=
time
.
Now
()
d
.
importQueue
=
hashes
d
.
importDone
=
0
d
.
importLock
.
Unlock
()
}
return
blocks
...
...
@@ -287,6 +297,7 @@ func (d *Downloader) Cancel() bool {
d
.
importLock
.
Lock
()
d
.
importQueue
=
nil
d
.
importDone
=
0
d
.
importLock
.
Unlock
()
return
true
...
...
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